From: Alexander Shishkin Date: Fri, 4 Mar 2016 14:16:31 +0000 (+0200) Subject: intel_th: msu: Handle kstrndup() failure X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6575cbd67172bbcbfbb50ddd854d2b90c9f4e358;p=openwrt%2Fstaging%2Fblogic.git intel_th: msu: Handle kstrndup() failure Currently, the nr_pages attribute store does not check if kstrndup() succeeded. Fix this. Reported-by: Alan Cox Signed-off-by: Alexander Shishkin Reviewed-by: Laurent Fert --- diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c index d9d6022c5aca..747ccf84bd93 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);