mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-20 08:52:12 +01:00
ti_sci: Prevent memory leak
temp is assigned the pointer returned by malloc which is used without a NULL check and then never freed. Add a NULL check and ensure temp is freed on all return paths. This issue was found by Smatch. Reviewed-by: Udit Kumar <u-kumar1@ti.com> Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> Reviewed-by: Nishanth Menon <nm@ti.com> Tested-by: Anshul Dalal <anshuld@ti.com>
This commit is contained in:
parent
a157a73720
commit
4b8bc5af80
@ -3083,7 +3083,10 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
|
|||||||
dev_err(dev, "%s resource type ids not available\n", of_prop);
|
dev_err(dev, "%s resource type ids not available\n", of_prop);
|
||||||
return ERR_PTR(sets);
|
return ERR_PTR(sets);
|
||||||
}
|
}
|
||||||
temp = malloc(sets);
|
temp = devm_kmalloc(dev, sets, GFP_KERNEL);
|
||||||
|
if (!temp)
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
sets /= sizeof(u32);
|
sets /= sizeof(u32);
|
||||||
res->sets = sets;
|
res->sets = sets;
|
||||||
|
|
||||||
@ -3123,6 +3126,7 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
|
|||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
devm_kfree(dev, temp);
|
||||||
if (valid_set)
|
if (valid_set)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user