* [PATCH] modpost: add NOFAIL to strndup
@ 2019-08-27 12:20 Denis Efremov
2019-08-28 15:56 ` Masahiro Yamada
0 siblings, 1 reply; 2+ messages in thread
From: Denis Efremov @ 2019-08-27 12:20 UTC (permalink / raw)
To: Masahiro Yamada, Michal Marek; +Cc: Denis Efremov, linux-kbuild, linux-kernel
Add NOFAIL check for the strndup call, because the function
allocates memory and can return NULL. All calls to strdup in
modpost are checked with NOFAIL.
Signed-off-by: Denis Efremov <efremov@linux.com>
---
scripts/mod/modpost.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index f277e116e0eb..0255538528fe 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -795,9 +795,9 @@ static int match(const char *sym, const char * const pat[])
/* "*foo*" */
if (*p == '*' && *endp == '*') {
- char *here, *bare = strndup(p + 1, strlen(p) - 2);
+ char *bare = NOFAIL(strndup(p + 1, strlen(p) - 2));
+ char *here = strstr(sym, bare);
- here = strstr(sym, bare);
free(bare);
if (here != NULL)
return 1;
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] modpost: add NOFAIL to strndup
2019-08-27 12:20 [PATCH] modpost: add NOFAIL to strndup Denis Efremov
@ 2019-08-28 15:56 ` Masahiro Yamada
0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2019-08-28 15:56 UTC (permalink / raw)
To: Denis Efremov
Cc: Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List
On Tue, Aug 27, 2019 at 9:20 PM Denis Efremov <efremov@linux.com> wrote:
>
> Add NOFAIL check for the strndup call, because the function
> allocates memory and can return NULL. All calls to strdup in
> modpost are checked with NOFAIL.
>
> Signed-off-by: Denis Efremov <efremov@linux.com>
> ---
Applied to linux-kbuild. Thanks.
> scripts/mod/modpost.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index f277e116e0eb..0255538528fe 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -795,9 +795,9 @@ static int match(const char *sym, const char * const pat[])
>
> /* "*foo*" */
> if (*p == '*' && *endp == '*') {
> - char *here, *bare = strndup(p + 1, strlen(p) - 2);
> + char *bare = NOFAIL(strndup(p + 1, strlen(p) - 2));
> + char *here = strstr(sym, bare);
>
> - here = strstr(sym, bare);
> free(bare);
> if (here != NULL)
> return 1;
> --
> 2.21.0
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-28 15:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 12:20 [PATCH] modpost: add NOFAIL to strndup Denis Efremov
2019-08-28 15:56 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome