[PATCH v4 4/4] Input: adp5589: fix possible memleak of 'kpad'

From: Alexandru Ardelean
Date: Thu Mar 05 2020 - 08:11:36 EST


If 'adp5589_i2c_get_driver_data()' returns an error, the exit path should
be to also free the 'kpad' object.
This change fixes that.

Reported-by: kbuild test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx>
---
drivers/input/keyboard/adp5589-keys.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
index 1fd36c581a91..5cef5a13b776 100644
--- a/drivers/input/keyboard/adp5589-keys.c
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -1050,7 +1050,7 @@ static int adp5589_probe(struct i2c_client *client,

ret = adp5589_i2c_get_driver_data(client, id);
if (ret < 0)
- return ret;
+ goto err_free_mem;

switch (ret) {
case ADP5585_02:
--
2.20.1