[PATCH][next] regmap: fix return of unintialized value in variable ret

From: Colin King
Date: Fri Sep 18 2020 - 09:27:11 EST


From: Colin Ian King <colin.king@xxxxxxxxxxxxx>

A recent commit removed the intialization of ret and now the !config
error return path returns a bogus uninitialized value in ret. Fix
this by explicitly setting ret to -EINVAL for this error exit path.

Addresses-Coverity: ("Uninitialized scalar value")
Fixes: 94cc89eb8fa5 ("regmap: debugfs: Fix handling of name string for debugfs init delays")
Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
---
drivers/base/regmap/regmap.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index d0f7cc574ff3..bd385b82f30b 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -710,8 +710,10 @@ struct regmap *__regmap_init(struct device *dev,
int i, j;
int ret;

- if (!config)
+ if (!config) {
+ ret = -EINVAL;
goto err;
+ }

map = kzalloc(sizeof(*map), GFP_KERNEL);
if (map == NULL) {
--
2.27.0