From: Gaurav Singh <gaurav1086@gmail.com>
To: gaurav1086@gmail.com, "Shuah Khan" <shuah@kernel.org>,
"Tejun Heo" <tj@kernel.org>, "Michal Koutný" <mkoutny@suse.com>,
"Roman Gushchin" <guro@fb.com>,
"Chris Down" <chris@chrisdown.name>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Christian Brauner" <christian.brauner@ubuntu.com>,
linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST
FRAMEWORK), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] [cgroup/testing] cg_read_strcmp: Fix null pointer dereference
Date: Sat, 25 Jul 2020 14:14:51 -0400 [thread overview]
Message-ID: <20200725181506.20199-1-gaurav1086@gmail.com> (raw)
Passing NULL in strcmp will cause a segmentation fault.
Fix this by returning -1 if expected is NULL pointer.
Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
tools/testing/selftests/cgroup/cgroup_util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 8a637ca7d73a..05853b0b8831 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -106,7 +106,7 @@ int cg_read_strcmp(const char *cgroup, const char *control,
/* Handle the case of comparing against empty string */
if (!expected)
- size = 32;
+ return -1;
else
size = strlen(expected) + 1;
--
2.17.1
next reply other threads:[~2020-07-25 18:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-25 18:14 Gaurav Singh [this message]
2020-07-25 20:23 ` [PATCH] [cgroup/testing] cg_read_strcmp: Fix null pointer dereference Chris Down
2020-07-26 1:37 ` Gaurav Singh
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=20200725181506.20199-1-gaurav1086@gmail.com \
--to=gaurav1086@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chris@chrisdown.name \
--cc=christian.brauner@ubuntu.com \
--cc=guro@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).