Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1563575 > unrolled thread

[PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference

Started byColin King <colin.king@canonical.com>
First post2017-01-20 14:30 +0100
Last post2017-01-29 16:30 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference Colin King <colin.king@canonical.com> - 2017-01-20 14:30 +0100
    Re: [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid  null pointer dereference Pali Rohár <pali.rohar@gmail.com> - 2017-01-21 01:10 +0100
    Re: [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid  null pointer dereference Sebastian Reichel <sre@kernel.org> - 2017-01-29 16:30 +0100

#1563575 — [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference

FromColin King <colin.king@canonical.com>
Date2017-01-20 14:30 +0100
Subject[PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference
Message-ID<t1Hqq-7M4-35@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1564001 — Re: [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference

FromPali Rohár <pali.rohar@gmail.com>
Date2017-01-21 01:10 +0100
SubjectRe: [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference
Message-ID<t1RpL-5D4-7@gated-at.bofh.it>
In reply to#1563575
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

[toc] | [prev] | [next] | [standalone]


#1569215 — Re: [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference

FromSebastian Reichel <sre@kernel.org>
Date2017-01-29 16:30 +0100
SubjectRe: [PATCH] power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference
Message-ID<t4ZAu-ge-17@gated-at.bofh.it>
In reply to#1563575

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web