Skip to content

Commit fd2575c

Browse files
jerome-pouillergregkh
authored andcommitted
staging: wfx: check memory allocation
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 <[email protected]> Signed-off-by: Jérôme Pouiller <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1cd8909 commit fd2575c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/staging/wfx/main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,18 @@ static int wfx_send_pdata_pds(struct wfx_dev *wdev)
222222
if (ret) {
223223
dev_err(wdev->dev, "can't load PDS file %s\n",
224224
wdev->pdata.file_pds);
225-
return ret;
225+
goto err1;
226226
}
227227
tmp_buf = kmemdup(pds->data, pds->size, GFP_KERNEL);
228+
if (!tmp_buf) {
229+
ret = -ENOMEM;
230+
goto err2;
231+
}
228232
ret = wfx_send_pds(wdev, tmp_buf, pds->size);
229233
kfree(tmp_buf);
234+
err2:
230235
release_firmware(pds);
236+
err1:
231237
return ret;
232238
}
233239

0 commit comments

Comments
 (0)