intel_th: msu: Handle kstrndup() failure
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Fri, 4 Mar 2016 14:16:31 +0000 (16:16 +0200)
committerAlexander Shishkin <alexander.shishkin@linux.intel.com>
Fri, 8 Apr 2016 13:11:55 +0000 (16:11 +0300)
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

index d9d6022c5aca42bbf959d214abb76b5ee3fe8704..747ccf84bd93c0eab75a03067d600ba943b09b89 100644 (file)
@@ -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);