public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Denis Efremov <efremov@linux.com>
To: linux-kernel@vger.kernel.org
Cc: Denis Efremov <efremov@linux.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Leonardo Bras <leobras.c@gmail.com>,
	Allison Randal <allison@lohutok.net>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] ASN.1: Fix NULL check after strdup call
Date: Tue, 27 Aug 2019 19:06:12 +0300	[thread overview]
Message-ID: <20190827160612.11114-1-efremov@linux.com> (raw)

strdup function returns a pointer to the newly allocated string,
or a NULL if an error occurred. Thus, grammar_name should be checked
right after strdup call. p variable can't be NULL in this context.
This follows from p check before the strdup call.

Signed-off-by: Denis Efremov <efremov@linux.com>
---
 scripts/asn1_compiler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
index adabd4145264..985fb81cae79 100644
--- a/scripts/asn1_compiler.c
+++ b/scripts/asn1_compiler.c
@@ -625,7 +625,7 @@ int main(int argc, char **argv)
 	p = strrchr(argv[1], '/');
 	p = p ? p + 1 : argv[1];
 	grammar_name = strdup(p);
-	if (!p) {
+	if (!grammar_name) {
 		perror(NULL);
 		exit(1);
 	}
-- 
2.21.0


                 reply	other threads:[~2019-08-27 16:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190827160612.11114-1-efremov@linux.com \
    --to=efremov@linux.com \
    --cc=allison@lohutok.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=leobras.c@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox