* [PATCH] ASN.1: Fix NULL check after strdup call
@ 2019-08-27 16:06 Denis Efremov
0 siblings, 0 replies; only message in thread
From: Denis Efremov @ 2019-08-27 16:06 UTC (permalink / raw)
To: linux-kernel
Cc: Denis Efremov, Greg Kroah-Hartman, Leonardo Bras, Allison Randal,
Masahiro Yamada, Thomas Gleixner
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-08-27 16:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-27 16:06 [PATCH] ASN.1: Fix NULL check after strdup call Denis Efremov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox