From: Yang Yingliang Date: Thu, 17 Nov 2022 07:06:36 +0000 (+0800) Subject: firmware: raspberrypi: fix possible memory leak in rpi_firmware_probe() X-Git-Tag: baikal/aarch64/sdk5.10~168 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=1c7b77acfa4f60c29f938da67864579730843a11;p=kernel.git firmware: raspberrypi: fix possible memory leak in rpi_firmware_probe() commit 7b51161696e803fd5f9ad55b20a64c2df313f95c upstream. 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: 2284abf319f5 ("firmware: raspberrypi: Keep count of all consumers") Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20221117070636.3849773-1-yangyingliang@huawei.com Acked-by: Joel Savitz Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 6a60b5bde0c98..1a690b2c1e2ff 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -261,6 +261,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; }