Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1383258

[QUEUED v20160420 10/19] intel_th: msu: Handle kstrndup() failure

From Alexander Shishkin <alexander.shishkin@linux.intel.com>
Newsgroups linux.kernel
Subject [QUEUED v20160420 10/19] intel_th: msu: Handle kstrndup() failure
Date 2016-04-20 12:50 +0200
Message-ID <rpXRM-6vx-19@gated-at.bofh.it> (permalink)
References <rpXRL-6vx-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Currently, the nr_pages attribute store does not check if kstrndup()
succeeded. Fix this.

Reported-by: Alan Cox <alan.cox@intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Laurent Fert <laurent.fert@intel.com>
---
 drivers/hwtracing/intel_th/msu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index d9d6022c5a..747ccf84bd 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1393,6 +1393,11 @@ nr_pages_store(struct device *dev, struct device_attribute *attr,
 	do {
 		end = memchr(p, ',', len);
 		s = kstrndup(p, end ? end - p : len, GFP_KERNEL);
+		if (!s) {
+			ret = -ENOMEM;
+			goto free_win;
+		}
+
 		ret = kstrtoul(s, 10, &val);
 		kfree(s);
 
-- 
2.8.0.rc3

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[QUEUED v20160420 10/19] intel_th: msu: Handle kstrndup() failure Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-20 12:50 +0200

csiph-web