summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-11-17 15:06:36 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-17 11:36:05 +0200
commit62ac943eb2a9d655e431b9bc98ff6d7bd51a0e49 (patch)
treef432bd1ee86dd96daa7bf7c0adf8a2162d0163b4
parenta781ea3437a08474844239003b65d8cc6a21baa7 (diff)
downloadlinux-stable-62ac943eb2a9d655e431b9bc98ff6d7bd51a0e49.tar.gz
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: 1e7c57355a3b ("firmware: raspberrypi: Keep count of all consumers") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20221117070636.3849773-1-yangyingliang@huawei.com Acked-by: Joel Savitz <jsavitz@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/firmware/raspberrypi.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 6a60b5bde0c9..1a690b2c1e2f 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;
}