Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9437fa5 authored by Colin Ian King's avatar Colin Ian King Committed by Greg Kroah-Hartman
Browse files

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: default avatarColin Ian King <colin.king@canonical.com>
Reviewed-by: default avatarPali Rohár <pali.rohar@gmail.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 98b62bd6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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) {