]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
regmap: fix kernel hang on regmap_bulk_write with zero val_count.
authorQuentin Casasnovas <quentin.casasnovas@oracle.com>
Wed, 12 Nov 2014 10:19:23 +0000 (11:19 +0100)
committerJiri Slaby <jslaby@suse.cz>
Thu, 13 Nov 2014 18:02:05 +0000 (19:02 +0100)
If val_count is zero we return -EINVAL with map->lock_arg locked, which
will deadlock the kernel next time we try to acquire this lock.

In 3.12, this was introduced by a0b8d8d906d267987d507138003048c5fdf774
("regmap: fix possible ZERO_SIZE_PTR pointer dereferencing error.")
which improperly back-ported d6b41cb06044a7d895db82bdd54f6e4219970510.

This issue was found during review of Ubuntu Trusty 3.13.0-40.68 kernel to
prepare Ksplice rebootless updates.

Fixes: f5942dd ("regmap: fix possible ZERO_SIZE_PTR pointer dereferencing error.")
Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/base/regmap/regmap.c

index 7a58be457eb52d999b0d6fe0ce8c5aa122834a93..9f799018765378d85901a601598d217121050a9b 100644 (file)
@@ -1403,8 +1403,10 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
        if (val_bytes == 1) {
                wval = (void *)val;
        } else {
-               if (!val_count)
-                       return -EINVAL;
+               if (!val_count) {
+                       ret = -EINVAL;
+                       goto out;
+               }
 
                wval = kmemdup(val, val_count * val_bytes, GFP_KERNEL);
                if (!wval) {