[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230809010026.GA4770@madhu-kernel>
Date: Tue, 8 Aug 2023 20:00:26 -0500
From: Madhumitha Prabakaran <madhumithabiw@...il.com>
To: hverkuil-cisco@...all.nl, mchehab@...nel.org,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: skhan@...uxfoundation.org, ivan.orlov0322@...il.com,
madhumithabiw@...il.com
Subject: [PATCH] media: usb: go7007: Fix warning: passing freed memory 'fw'
Fix smatch warning - go7007_loader_probe() warn: passing freed memory 'fw'
The 'fw' pointer is released using release_firmware(fw) and then being used
again in another request_firmware() call without being reassigned to a new
memory allocation. To resolve it, use separate variables for each request.
Signed-off-by: Madhumitha Prabakaran <madhumithabiw@...il.com>
---
drivers/media/usb/go7007/go7007-loader.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/media/usb/go7007/go7007-loader.c b/drivers/media/usb/go7007/go7007-loader.c
index 243aa0ad074c..5f5c425f4d45 100644
--- a/drivers/media/usb/go7007/go7007-loader.c
+++ b/drivers/media/usb/go7007/go7007-loader.c
@@ -35,7 +35,7 @@ static int go7007_loader_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
struct usb_device *usbdev;
- const struct firmware *fw;
+ const struct firmware *fw_1, *fw_2;
u16 vendor, product;
const char *fw1, *fw2;
int ret;
@@ -67,13 +67,13 @@ static int go7007_loader_probe(struct usb_interface *interface,
dev_info(&interface->dev, "loading firmware %s\n", fw1);
- if (request_firmware(&fw, fw1, &usbdev->dev)) {
+ if (request_firmware(&fw_1, fw1, &usbdev->dev)) {
dev_err(&interface->dev,
"unable to load firmware from file \"%s\"\n", fw1);
goto failed2;
}
- ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
- release_firmware(fw);
+ ret = cypress_load_firmware(usbdev, fw_1, CYPRESS_FX2);
+ release_firmware(fw_1);
if (0 != ret) {
dev_err(&interface->dev, "loader download failed\n");
goto failed2;
@@ -82,13 +82,13 @@ static int go7007_loader_probe(struct usb_interface *interface,
if (fw2 == NULL)
return 0;
- if (request_firmware(&fw, fw2, &usbdev->dev)) {
+ if (request_firmware(&fw_2, fw2, &usbdev->dev)) {
dev_err(&interface->dev,
"unable to load firmware from file \"%s\"\n", fw2);
goto failed2;
}
- ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
- release_firmware(fw);
+ ret = cypress_load_firmware(usbdev, fw_2, CYPRESS_FX2);
+ release_firmware(fw_2);
if (0 != ret) {
dev_err(&interface->dev, "firmware download failed\n");
goto failed2;
--
2.25.1
Powered by blists - more mailing lists