diff options
author | Colin Ian King <colin.king@canonical.com> | 2017-01-20 16:25:06 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-04-29 12:31:56 +0300 |
commit | f9437fa5d27bd475017107a59a246c7eb4045b57 (patch) | |
tree | 00cfbd861ea44b81a0d5e2a0fbaa8cd46994e724 /drivers/power/supply/bq2415x_charger.c | |
parent | 98b62bd6823dc7da57a940b84c5e16fd459dc50e (diff) | |
download | linux-f9437fa5d27bd475017107a59a246c7eb4045b57.tar.xz |
power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference
commit a1b94355ea3fde5e13db7ff37c0272fcde4e29b2 upstream.
acpi_match_device can potentially return NULL, so it is prudent to
check if acpi_id is null before it is dereferenced. Add a check
and an error message to indicate the failure.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/power/supply/bq2415x_charger.c')
-rw-r--r-- | drivers/power/supply/bq2415x_charger.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c index 73e2f0b79dd4..c4770a94cc8e 100644 --- a/drivers/power/supply/bq2415x_charger.c +++ b/drivers/power/supply/bq2415x_charger.c @@ -1569,6 +1569,11 @@ static int bq2415x_probe(struct i2c_client *client, acpi_id = acpi_match_device(client->dev.driver->acpi_match_table, &client->dev); + if (!acpi_id) { + dev_err(&client->dev, "failed to match device name\n"); + ret = -ENODEV; + goto error_1; + } name = kasprintf(GFP_KERNEL, "%s-%d", acpi_id->id, num); } if (!name) { |