mtd: spear_smi: add NULL check on devm_kzalloc() return value
Check return value from call to devm_kzalloc() in order to prevent a NULL pointer dereference. This issue was detected using Coccinelle and the following semantic patch: @@ expression x; identifier fld; @@ * x = devm_kzalloc(...); ... when != x == NULL x->fld Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
This commit is contained in:
parent
1fbef470f3
commit
90cc62f343
|
@ -775,6 +775,8 @@ static int spear_smi_probe_config_dt(struct platform_device *pdev,
|
||||||
pdata->board_flash_info = devm_kzalloc(&pdev->dev,
|
pdata->board_flash_info = devm_kzalloc(&pdev->dev,
|
||||||
sizeof(*pdata->board_flash_info),
|
sizeof(*pdata->board_flash_info),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
if (!pdata->board_flash_info)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Fill structs for each subnode (flash device) */
|
/* Fill structs for each subnode (flash device) */
|
||||||
while ((pp = of_get_next_child(np, pp))) {
|
while ((pp = of_get_next_child(np, pp))) {
|
||||||
|
|
Loading…
Reference in New Issue