From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam01on0123.outbound.protection.outlook.com ([104.47.34.123]:51712 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727338AbeH3WFB (ORCPT ); Thu, 30 Aug 2018 18:05:01 -0400 From: Sasha Levin To: "stable@vger.kernel.org" CC: Randy Dunlap , Yuexing Wang , Masahiro Yamada , Sasha Levin Subject: [PATCH AUTOSEL 4.18 016/113] scripts: modpost: check memory allocation results Date: Thu, 30 Aug 2018 18:01:40 +0000 Message-ID: <20180830180050.35735-16-alexander.levin@microsoft.com> References: <20180830180050.35735-1-alexander.levin@microsoft.com> In-Reply-To: <20180830180050.35735-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Randy Dunlap [ Upstream commit 1f3aa9002dc6a0d59a4b599b4fc8f01cf43ef014 ] Fix missing error check for memory allocation functions in scripts/mod/modpost.c. Fixes kernel bugzilla #200319: https://bugzilla.kernel.org/show_bug.cgi?id=3D200319 Signed-off-by: Randy Dunlap Cc: Yuexing Wang Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- scripts/mod/modpost.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 1663fb19343a..b95cf57782a3 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -672,7 +672,7 @@ static void handle_modversions(struct module *mod, stru= ct elf_info *info, if (ELF_ST_TYPE(sym->st_info) =3D=3D STT_SPARC_REGISTER) break; if (symname[0] =3D=3D '.') { - char *munged =3D strdup(symname); + char *munged =3D NOFAIL(strdup(symname)); munged[0] =3D '_'; munged[1] =3D toupper(munged[1]); symname =3D munged; @@ -1318,7 +1318,7 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf= , Elf_Addr addr, static char *sec2annotation(const char *s) { if (match(s, init_exit_sections)) { - char *p =3D malloc(20); + char *p =3D NOFAIL(malloc(20)); char *r =3D p; =20 *p++ =3D '_'; @@ -1338,7 +1338,7 @@ static char *sec2annotation(const char *s) strcat(p, " "); return r; } else { - return strdup(""); + return NOFAIL(strdup("")); } } =20 @@ -2036,7 +2036,7 @@ void buf_write(struct buffer *buf, const char *s, int= len) { if (buf->size - buf->pos < len) { buf->size +=3D len + SZ; - buf->p =3D realloc(buf->p, buf->size); + buf->p =3D NOFAIL(realloc(buf->p, buf->size)); } strncpy(buf->p + buf->pos, s, len); buf->pos +=3D len; --=20 2.17.1