From: Madhumitha Prabakaran <madhumithabiw@gmail.com>
To: hverkuil-cisco@xs4all.nl, mchehab@kernel.org,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: skhan@linuxfoundation.org, ivan.orlov0322@gmail.com,
madhumithabiw@gmail.com
Subject: [PATCH] media: usb: go7007: Fix warning: passing freed memory 'fw'
Date: Tue, 8 Aug 2023 20:00:26 -0500 [thread overview]
Message-ID: <20230809010026.GA4770@madhu-kernel> (raw)
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@gmail.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
next reply other threads:[~2023-08-09 1:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 1:00 Madhumitha Prabakaran [this message]
2023-08-11 9:58 ` [PATCH] media: usb: go7007: Fix warning: passing freed memory 'fw' Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230809010026.GA4770@madhu-kernel \
--to=madhumithabiw@gmail.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=ivan.orlov0322@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox