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 <dan.carpenter@oracle.com> Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20201009171307.864608-3-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
1cd8909642
commit
fd2575c4a4
|
@ -222,12 +222,18 @@ static int wfx_send_pdata_pds(struct wfx_dev *wdev)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(wdev->dev, "can't load PDS file %s\n",
|
dev_err(wdev->dev, "can't load PDS file %s\n",
|
||||||
wdev->pdata.file_pds);
|
wdev->pdata.file_pds);
|
||||||
return ret;
|
goto err1;
|
||||||
}
|
}
|
||||||
tmp_buf = kmemdup(pds->data, pds->size, GFP_KERNEL);
|
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);
|
ret = wfx_send_pds(wdev, tmp_buf, pds->size);
|
||||||
kfree(tmp_buf);
|
kfree(tmp_buf);
|
||||||
|
err2:
|
||||||
release_firmware(pds);
|
release_firmware(pds);
|
||||||
|
err1:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue