Re: [PATCH v4 03/12] i3c: master: Support ACPI enumeration of child devices
Frank Li <[email protected]>
| Newsgroups | org.infradead.lists.linux-i3c,dev.linux.lists.sashiko-reviews,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-hwmon |
|---|---|
| Message-ID | <ajRMqilbGEi6CsLc@lizhi-Precision-Tower-5810> |
On Tue, Jun 16, 2026 at 10:15:14AM +0000, [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [Medium] devm_kzalloc allocated 'boardinfo' is leaked for every ACPI child node that is ignored because it lacks I2C/I3C resources. > -- > > commit 9a388c2056a553d628ce4b8b623a812d4aa08951 > Author: Akhil R <[email protected]> > > i3c: master: Support ACPI enumeration of child devices > > This commit adds support for describing I3C and I2C devices via ACPI tables, > rather than relying solely on the device tree reg property. It implements > reading _ADR and LVR properties from ACPI resources to retrieve the static > address and other device properties. > > > diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c > > index 3b19a5e8f46d0..f0e05bcac26da 100644 > > --- a/drivers/i3c/master.c > > +++ b/drivers/i3c/master.c > > [ ... ] > > > @@ -2708,6 +2762,74 @@ static int i3c_master_add_dev(struct i3c_master_controller *master, > > return ret; > > } > > > > +#ifdef CONFIG_ACPI > > +static int i3c_master_add_acpi_dev(struct i3c_master_controller *master, > > + struct fwnode_handle *fwnode) > > +{ > > + struct acpi_device *adev = to_acpi_device_node(fwnode); > > + acpi_bus_address adr; > > + u32 reg[3] = { 0 }; > > + int ret; > > + > > + /* > > + * If the ACPI table entry has _ADR method, it's an I3C device. > > + * Otherwise it may be an I2C device described by an I2cSerialBus > > + * resource. If no I2cSerialBus resource is found, ignore the entry. > > + */ > > + if (!acpi_has_method(adev->handle, "_ADR")) { > > + ret = i3c_master_add_i2c_boardinfo(master, fwnode, reg); > > + if (ret == -ENODEV) > > + return 0; > > [Severity: Medium] > Does this leak the boardinfo allocated in i3c_master_add_i2c_boardinfo()? > > If an ACPI child lacks an _ADR method, i3c_master_add_i2c_boardinfo() > unconditionally allocates boardinfo using devm_kzalloc(). > > If the node also lacks an I2cSerialBus resource, i3c_acpi_add_i2c_boardinfo() > returns -ENODEV. This causes i3c_master_add_i2c_boardinfo() to return -ENODEV > without freeing the allocated boardinfo. > > Because we catch -ENODEV here and return 0, the overall bus probe continues > and ultimately succeeds. This means the devres-allocated memory stays tied > to the master device, leaking sizeof(struct i2c_dev_boardinfo) for every > ignored ACPI child node. Is it true? Frank > > > + > > + return ret; > > + } > > + > > + adr = acpi_device_adr(adev); > > [ ... ] > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c