summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2020-03-12 14:32:44 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-03-18 07:14:25 +0100
commit9dda737464fc0a05d69d75a9af21f2df645a7bc0 (patch)
tree0f5307287df82f8a3a324de1a941a11c8f73d82e
parent7967fef2c6aac905233eba29f047772f1392aefb (diff)
downloadlinux-stable-9dda737464fc0a05d69d75a9af21f2df645a7bc0.tar.gz
linux-stable-9dda737464fc0a05d69d75a9af21f2df645a7bc0.tar.bz2
linux-stable-9dda737464fc0a05d69d75a9af21f2df645a7bc0.zip
i2c: acpi: put device when verifying client fails
commit 8daee952b4389729358665fb91949460641659d4 upstream. i2c_verify_client() can fail, so we need to put the device when that happens. Fixes: 525e6fabeae2 ("i2c / ACPI: add support for ACPI reconfigure notifications") Reported-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/i2c/i2c-core-acpi.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 559c3b1284d7..eb0569359387 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -352,10 +352,18 @@ static struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev)
{
struct device *dev;
+ struct i2c_client *client;
dev = bus_find_device(&i2c_bus_type, NULL, adev,
i2c_acpi_find_match_device);
- return dev ? i2c_verify_client(dev) : NULL;
+ if (!dev)
+ return NULL;
+
+ client = i2c_verify_client(dev);
+ if (!client)
+ put_device(dev);
+
+ return client;
}
static int i2c_acpi_notify(struct notifier_block *nb, unsigned long value,