[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201009171307.864608-3-Jerome.Pouiller@silabs.com>
Date: Fri, 9 Oct 2020 19:13:01 +0200
From: Jerome Pouiller <Jerome.Pouiller@...abs.com>
To: devel@...verdev.osuosl.org, linux-wireless@...r.kernel.org
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Kalle Valo <kvalo@...eaurora.org>,
"David S . Miller" <davem@...emloft.net>,
Dan Carpenter <dan.carpenter@...cle.com>,
Jérôme Pouiller
<jerome.pouiller@...abs.com>
Subject: [PATCH 2/8] staging: wfx: check memory allocation
From: Jérôme Pouiller <jerome.pouiller@...abs.com>
Smatch complains:
main.c:228 wfx_send_pdata_pds() warn: potential NULL parameter dereference 'tmp_buf'
227 tmp_buf = kmemdup(pds->data, pds->size, GFP_KERNEL);
228 ret = wfx_send_pds(wdev, tmp_buf, pds->size);
^^^^^^^
229 kfree(tmp_buf);
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Jérôme Pouiller <jerome.pouiller@...abs.com>
---
drivers/staging/wfx/main.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index df11c091e094..a8dc2c033410 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -222,12 +222,18 @@ static int wfx_send_pdata_pds(struct wfx_dev *wdev)
if (ret) {
dev_err(wdev->dev, "can't load PDS file %s\n",
wdev->pdata.file_pds);
- return ret;
+ goto err1;
}
tmp_buf = kmemdup(pds->data, pds->size, GFP_KERNEL);
+ if (!tmp_buf) {
+ ret = -ENOMEM;
+ goto err2;
+ }
ret = wfx_send_pds(wdev, tmp_buf, pds->size);
kfree(tmp_buf);
+err2:
release_firmware(pds);
+err1:
return ret;
}
--
2.28.0
Powered by blists - more mailing lists