forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kbuild robot reports that since commit ce76d93 ("lib: Add memcat_p(): paste 2 pointer arrays together") the ia64/hp/sim/boot fails to link: > LD arch/ia64/hp/sim/boot/bootloader > lib/string.o: In function `__memcat_p': > string.c:(.text+0x1f22): undefined reference to `__kmalloc' > string.c:(.text+0x1ff2): undefined reference to `__kmalloc' > make[1]: *** [arch/ia64/hp/sim/boot/Makefile:37: arch/ia64/hp/sim/boot/bootloader] Error 1 The reason is, the above commit, via __memcat_p(), adds a call to __kmalloc to string.o, which happens to be used in the bootloader, but there's no kmalloc or slab or anything. Since the linker would only pull in objects that contain referenced symbols, moving __memcat_p() to a different compilation unit solves the problem. Fixes: ce76d93 ("lib: Add memcat_p(): paste 2 pointer arrays together") Signed-off-by: Alexander Shishkin <[email protected]> Reported-by: kbuild test robot <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Tony Luck <[email protected]> Cc: Joe Perches <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
- Loading branch information
Showing
4 changed files
with
36 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/slab.h> | ||
|
||
/* | ||
* Merge two NULL-terminated pointer arrays into a newly allocated | ||
* array, which is also NULL-terminated. Nomenclature is inspired by | ||
* memset_p() and memcat() found elsewhere in the kernel source tree. | ||
*/ | ||
void **__memcat_p(void **a, void **b) | ||
{ | ||
void **p = a, **new; | ||
int nr; | ||
|
||
/* count the elements in both arrays */ | ||
for (nr = 0, p = a; *p; nr++, p++) | ||
; | ||
for (p = b; *p; nr++, p++) | ||
; | ||
/* one for the NULL-terminator */ | ||
nr++; | ||
|
||
new = kmalloc_array(nr, sizeof(void *), GFP_KERNEL); | ||
if (!new) | ||
return NULL; | ||
|
||
/* nr -> last index; p points to NULL in b[] */ | ||
for (nr--; nr >= 0; nr--, p = p == b ? &a[nr] : p - 1) | ||
new[nr] = *p; | ||
|
||
return new; | ||
} | ||
EXPORT_SYMBOL_GPL(__memcat_p); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters