[PATCH] firmware: raspberrypi: fix possible memory leak in rpi_firmware_probe()

Joel Savitz jsavitz at redhat.com
Thu Nov 17 06:59:49 PST 2022


On Thu, Nov 17, 2022 at 3:08 AM Yang Yingliang <yangyingliang at huawei.com> wrote:
>
> In rpi_firmware_probe(), if mbox_request_channel() fails, the 'fw' will
> not be freed through rpi_firmware_delete(), fix this leak by calling
> kfree() in the error path.
>
> Fixes: 1e7c57355a3b ("firmware: raspberrypi: Keep count of all consumers")
> Signed-off-by: Yang Yingliang <yangyingliang at huawei.com>
> ---
>  drivers/firmware/raspberrypi.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
> index 4b8978b254f9..dba315f675bc 100644
> --- a/drivers/firmware/raspberrypi.c
> +++ b/drivers/firmware/raspberrypi.c
> @@ -272,6 +272,7 @@ static int rpi_firmware_probe(struct platform_device *pdev)
>                 int ret = PTR_ERR(fw->chan);
>                 if (ret != -EPROBE_DEFER)
>                         dev_err(dev, "Failed to get mbox channel: %d\n", ret);
> +               kfree(fw);
>                 return ret;
>         }
>
> --
> 2.25.1
>
>
> _______________________________________________
> linux-rpi-kernel mailing list
> linux-rpi-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel
>

Acked-by: Joel Savitz <jsavitz at redhat.com>




More information about the linux-rpi-kernel mailing list