* [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference
@ 2017-01-20 13:25 Colin King
2017-01-21 0:02 ` Pali Rohár
2017-01-29 15:17 ` Sebastian Reichel
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2017-01-20 13:25 UTC (permalink / raw)
To: Pali Rohár, Sebastian Reichel, linux-pm; +Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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>
---
drivers/power/supply/bq2415x_charger.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c
index 73e2f0b..c4770a9 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) {
--
2.10.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference
2017-01-20 13:25 [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference Colin King
@ 2017-01-21 0:02 ` Pali Rohár
2017-01-29 15:17 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Pali Rohár @ 2017-01-21 0:02 UTC (permalink / raw)
To: Colin King; +Cc: Sebastian Reichel, linux-pm, linux-kernel
On Friday 20 January 2017 13:25:06 Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
> ---
> drivers/power/supply/bq2415x_charger.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c
> index 73e2f0b..c4770a9 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) {
Looks good! Add my Reviewed-by.
--
Pali Rohár
pali.rohar@gmail.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference
2017-01-20 13:25 [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference Colin King
2017-01-21 0:02 ` Pali Rohár
@ 2017-01-29 15:17 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2017-01-29 15:17 UTC (permalink / raw)
To: Colin King; +Cc: Pali Rohár, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
Hi,
On Fri, Jan 20, 2017 at 01:25:06PM +0000, Colin King wrote:
> 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>
Thanks, queued into power-supply's for-next branch.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-29 15:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-20 13:25 [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference Colin King
2017-01-21 0:02 ` Pali Rohár
2017-01-29 15:17 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).