Skip to content

Commit a1b9435

Browse files
Colin Ian Kingsre
authored andcommitted
power: supply: bq2415x: check for NULL acpi_id to avoid null pointer dereference
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>
1 parent cb190af commit a1b9435

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/power/supply/bq2415x_charger.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,11 @@ static int bq2415x_probe(struct i2c_client *client,
15691569
acpi_id =
15701570
acpi_match_device(client->dev.driver->acpi_match_table,
15711571
&client->dev);
1572+
if (!acpi_id) {
1573+
dev_err(&client->dev, "failed to match device name\n");
1574+
ret = -ENODEV;
1575+
goto error_1;
1576+
}
15721577
name = kasprintf(GFP_KERNEL, "%s-%d", acpi_id->id, num);
15731578
}
15741579
if (!name) {

0 commit comments

Comments
 (0)