Re: [PATCH net-next v5 17/17] net: pse-pd: Add TI TPS23881 PSE controller driver

From: Simon Horman
Date: Wed Feb 28 2024 - 07:54:39 EST


On Tue, Feb 27, 2024 at 03:42:59PM +0100, Kory Maincent wrote:
> Add a new driver for the TI TPS23881 I2C Power Sourcing Equipment
> controller.
>
> This patch is sponsored by Dent Project <dentproject@xxxxxxxxxxxxxxxxxxx>.
>
> Signed-off-by: Kory Maincent <kory.maincent@xxxxxxxxxxx>

..

> +static int tps23881_flash_fw_part(struct i2c_client *client,
> + const char *fw_name,
> + const struct tps23881_fw_conf *fw_conf)
> +{
> + const struct firmware *fw = NULL;
> + int i, ret;
> +
> + ret = request_firmware(&fw, fw_name, &client->dev);
> + if (ret)
> + return ret;
> +
> + dev_info(&client->dev, "Flashing %s\n", fw_name);
> +
> + /* Prepare device for RAM download */
> + while (fw_conf->reg) {
> + ret = i2c_smbus_write_byte_data(client, fw_conf->reg,
> + fw_conf->val);
> + if (ret < 0)

Hi Kory,

Should fw be released here.

> + return ret;
> +
> + fw_conf++;
> + }
> +
> + /* Flash the firmware file */
> + for (i = 0; i < fw->size; i++) {
> + ret = i2c_smbus_write_byte_data(client,
> + TPS23881_REG_SRAM_DATA,
> + fw->data[i]);
> + if (ret < 0)

And here?

Flagged by Smatch.

> + return ret;
> + }
> +
> + release_firmware(fw);
> +
> + return 0;
> +}

..