Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Reza Kurniawan" <imkyufie@gmail.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 1/2] power: supply: bq256xx: Expose VBUS state through extcon
Date: Sat, 12 Sep 2026 15:29:28 +0000	[thread overview]
Message-ID: <20260912152928.7C7031F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260912-riva-usb-v2-1-997fe0171ee5@gmail.com>

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

Pre-existing issues:
- [Critical] This problem wasn't introduced by this patch, but an uninitialized stack pointer bat_info is dereferenced in the error path if battery info is missing.
--

commit 63c7018777c13e9b5077c305354b34365e65a932
Author: Reza Kurniawan <imkyufie@gmail.com>

power: supply: bq256xx: Expose VBUS state through extcon

Useful for USB controllers needing to sense VBUS state changes. This is
needed for devices like Xiaomi Redmi 5A (riva) that doesn't have its VBUS
session comparator wired directly to the USB connector pin to automatically
enable certain USB functions upon the presence of a USB power input.

> diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c
> index 4b1f81b1ed867..454bc497b0d81 100644
> --- a/drivers/power/supply/bq256xx_charger.c
> +++ b/drivers/power/supply/bq256xx_charger.c

[ ... ]

> @@ -1743,6 +1817,12 @@ static int bq256xx_probe(struct i2c_client *client)
>  	if (!IS_ERR_OR_NULL(bq->usb3_phy))
>  		usb_register_notifier(bq->usb3_phy, &bq->usb_nb);
>  
> +	ret = bq256xx_extcon_init(bq);
> +	if (ret) {
> +		dev_err(dev, "Failed to register extcon device\n");
> +		return ret;
> +	}
> +
>  	if (client->irq) {
>  		ret = devm_request_threaded_irq(dev, client->irq, NULL,
>  						bq256xx_irq_handler_thread,

[Severity: Critical]
This isn't a bug introduced by this patch, but looking at bq256xx_hw_init()
called shortly after this block in bq256xx_probe(), is it possible for the
bat_info pointer to remain uninitialized and cause memory corruption?

If power_supply_get_battery_info() returns an error other than -ENOMEM
(such as -ENODEV when no "monitored-battery" node is defined), bat_info
remains uninitialized, but it is then dereferenced in the error handling
path:

drivers/power/supply/bq256xx_charger.c:bq256xx_hw_init() {
	struct power_supply_battery_info *bat_info;
	...
	ret = power_supply_get_battery_info(bq->charger, &bat_info);
	if (ret == -ENOMEM)
		return ret;

	if (ret) {
		dev_warn(bq->dev, "battery info missing, default values will be applied\n");

		bat_info->constant_charge_current_max_ua =
				bq->chip_info->bq256xx_def_ichg;
	...
}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260912-riva-usb-v2-0-997fe0171ee5@gmail.com?part=1

  reply	other threads:[~2026-09-12 15:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12 15:18 [PATCH v2 0/2] Enable USB support (peripheral mode) for Xiaomi Redmi 5A (riva) Reza Kurniawan
2026-09-12 15:18 ` [PATCH v2 1/2] power: supply: bq256xx: Expose VBUS state through extcon Reza Kurniawan
2026-09-12 15:29   ` sashiko-bot [this message]
2026-09-12 15:18 ` [PATCH v2 2/2] arm64: dts: qcom: msm8917-xiaomi-riva: Enable USB support (peripheral mode) Reza Kurniawan

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=20260912152928.7C7031F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imkyufie@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox