All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Henrik Grimler" <henrik.grimler@axis.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746
Date: Tue, 18 Aug 2026 09:57:39 +0000	[thread overview]
Message-ID: <20260818095739.7EBFF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260818-bq27z746-v2-3-0371e206665f@axis.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Potential null pointer dereference in `bq27xxx_battery_i2c_probe()` when retrieving the I2C device ID. The driver relies on `i2c_client_get_device_id()` without checking its return value.
--

--- Patch [3]: [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746 ---
commit a0624890a79f9b2398a034239df6144de2c581e9
Author: Henrik Grimler <henrik.grimler@axis.com>

power: supply: bq27xxx: add support for bq27z746

bq27z746 is similar to bq27z561, but has additional battery protection
logic. The standard register map is a subset of the one found in
bq27z561.

> diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
> index c4e7a9521d086..2a6b4534cb28a 100644
> --- a/drivers/power/supply/bq27xxx_battery_i2c.c
> +++ b/drivers/power/supply/bq27xxx_battery_i2c.c
> @@ -253,6 +253,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
>  	{ .name = "bq27441", .driver_data = BQ27441 },
>  	{ .name = "bq27621", .driver_data = BQ27621 },
>  	{ .name = "bq27z561", .driver_data = BQ27Z561 },
> +	{ .name = "bq27z746", .driver_data = BQ27Z746 },

[Severity: High]
This is a pre-existing issue, but adding a new device id highlights a
potential null pointer dereference in bq27xxx_battery_i2c_probe().

If a system integrator provides a Device Tree containing a valid fallback
compatible string (for example: compatible = "ti,unsupported-chip",
"ti,bq27z746";), probe could be called with client->name set to
"unsupported-chip".

Since "unsupported-chip" is not in the I2C ID table,
i2c_client_get_device_id() will return NULL:

static int bq27xxx_battery_i2c_probe(struct i2c_client *client)
{
	const struct i2c_device_id *id = i2c_client_get_device_id(client);
	...
	name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%ld", id->name, num);
	...
	di->chip = id->driver_data;
	...
}

Does this code cause a kernel panic when id->name and id->driver_data are
accessed if id is NULL? Would it be safer to explicitly check if id is
valid, or use i2c_get_match_data() to retrieve the driver_data?

>  	{ .name = "bq28z610", .driver_data = BQ28Z610 },

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260818-bq27z746-v2-0-0371e206665f@axis.com?part=3

      reply	other threads:[~2026-08-18  9:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18  9:48 [PATCH v2 0/3] power: supply: bq27xxx: add bq27z746 Henrik Grimler
2026-08-18  9:48 ` [PATCH v2 1/3] dt-bindings: power: bq27xxx: bq27z561: allow interrupts property Henrik Grimler
2026-08-18  9:48 ` [PATCH v2 2/3] dt-bindings: power: bq27xxx: document bq27z746 Henrik Grimler
2026-08-18  9:48 ` [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746 Henrik Grimler
2026-08-18  9:57   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260818095739.7EBFF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=henrik.grimler@axis.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.