diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index b903aff59af3..e677a1b79f95 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1659,6 +1659,9 @@ out: } else { void *wval; + if (!val_count) + return -EINVAL; + wval = kmemdup(val, val_count * val_bytes, GFP_KERNEL); if (!wval) { dev_err(map->dev, "Error in memory allocation\n");