diff mbox series

modpost: add NOFAIL to strndup

Message ID 20190827122023.15086-1-efremov@linux.com (mailing list archive)
State New, archived
Headers show
Series modpost: add NOFAIL to strndup | expand

Commit Message

Denis Efremov (Oracle) Aug. 27, 2019, 12:20 p.m. UTC
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(-)

Comments

Masahiro Yamada Aug. 28, 2019, 3:56 p.m. UTC | #1
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
>
diff mbox series

Patch

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;