aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorXiubo Li <Li.Xiubo@freescale.com>2014-04-30 05:31:08 -0400
committerMark Brown <broonie@linaro.org>2014-04-30 23:33:57 -0400
commitf5727cd31283aa478f7f9396c6eb7b5aceebb869 (patch)
treedb763dd8418489159f01bb5397d7895df81ca610 /drivers/base
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
regmap: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
Since we cannot make sure the 'len = pair_size * num_regs' will always be none zero from the users, and then if 'num_regs' equals to zero by mistake or other reasons, the kzalloc() will return ZERO_SIZE_PTR, which equals to ((void *)16). So this patch fix this with just doing the 'len' zero check before calling kzalloc(). Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regmap.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 63e30ef096e2..9596f3048939 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1615,6 +1615,9 @@ static int _regmap_raw_multi_reg_write(struct regmap *map,
1615 size_t pair_size = reg_bytes + pad_bytes + val_bytes; 1615 size_t pair_size = reg_bytes + pad_bytes + val_bytes;
1616 size_t len = pair_size * num_regs; 1616 size_t len = pair_size * num_regs;
1617 1617
1618 if (!len)
1619 return -EINVAL;
1620
1618 buf = kzalloc(len, GFP_KERNEL); 1621 buf = kzalloc(len, GFP_KERNEL);
1619 if (!buf) 1622 if (!buf)
1620 return -ENOMEM; 1623 return -ENOMEM;