mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 06:33:07 +00:00
i2c: iop3xx: Fix memory leak in probe error path
When handling devm_gpiod_get_optional() errors, free the memory already
allocated. This fixes Smatch warnings:
drivers/i2c/busses/i2c-iop3xx.c:437 iop3xx_i2c_probe() warn: possible memory leak of 'new_adapter'
drivers/i2c/busses/i2c-iop3xx.c:442 iop3xx_i2c_probe() warn: possible memory leak of 'new_adapter'
Fixes: fdb7e884ad
("i2c: iop: Use GPIO descriptors")
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
parent
24a49678f5
commit
e64175776d
1 changed files with 8 additions and 4 deletions
|
@ -433,13 +433,17 @@ iop3xx_i2c_probe(struct platform_device *pdev)
|
||||||
adapter_data->gpio_scl = devm_gpiod_get_optional(&pdev->dev,
|
adapter_data->gpio_scl = devm_gpiod_get_optional(&pdev->dev,
|
||||||
"scl",
|
"scl",
|
||||||
GPIOD_ASIS);
|
GPIOD_ASIS);
|
||||||
if (IS_ERR(adapter_data->gpio_scl))
|
if (IS_ERR(adapter_data->gpio_scl)) {
|
||||||
return PTR_ERR(adapter_data->gpio_scl);
|
ret = PTR_ERR(adapter_data->gpio_scl);
|
||||||
|
goto free_both;
|
||||||
|
}
|
||||||
adapter_data->gpio_sda = devm_gpiod_get_optional(&pdev->dev,
|
adapter_data->gpio_sda = devm_gpiod_get_optional(&pdev->dev,
|
||||||
"sda",
|
"sda",
|
||||||
GPIOD_ASIS);
|
GPIOD_ASIS);
|
||||||
if (IS_ERR(adapter_data->gpio_sda))
|
if (IS_ERR(adapter_data->gpio_sda)) {
|
||||||
return PTR_ERR(adapter_data->gpio_sda);
|
ret = PTR_ERR(adapter_data->gpio_sda);
|
||||||
|
goto free_both;
|
||||||
|
}
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
|
|
Loading…
Reference in a new issue