firmware: raspberrypi: fix possible memory leak in rpi_firmware_probe()
authorYang Yingliang <yangyingliang@huawei.com>
Thu, 17 Nov 2022 07:06:36 +0000 (15:06 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:29 +0000 (13:14 +0100)
commitb308fdedef095aac14569f810d46edf773ea7d1e
treefbaabb2392d86c7c3dac37fe953f54c2a384b6c0
parentd5c8f9003a289ee2a9b564d109e021fc4d05d106
firmware: raspberrypi: fix possible memory leak in rpi_firmware_probe()

[ Upstream commit 7b51161696e803fd5f9ad55b20a64c2df313f95c ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/raspberrypi.c