soc: ti: ti_sci_pm_domains: Check for null return of devm_kcalloc
PATCH 1/1 soc: ti: ti_sci_pm_domains: Check for null return of devm_kcalloc
The allocation funciton devm_kcalloc may fail and return a null pointer, which would cause a null-pointer dereference later.
It might be better to check it and directly return -ENOMEM just like the usage of devm_kcalloc in previous code.
--- drivers/soc/ti/ti_sci_pm_domains.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/ti/ti_sci_pm_domains.c +2 -0
@@ -183,6 +183,8 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)devm_kcalloc (dev, max_id +1 ,sizeof (*pd_provider->data.domains),GFP_KERNEL ); +if (!pd_provider->data.domains) +return -ENOMEM ; pd_provider->data.num_domains = max_id +1 ; pd_provider->data.xlate = ti_sci_pd_xlate;
Signature · 1 line
2.7.4
Hi QintaoShen,
Quoted 6 lines · QintaoShen
The allocation funciton
devm_kcallocmay fail and return a null pointer, which would cause a null-pointer dereference later.
It might be better to check it and directly return-ENOMEMjust like the usage ofdevm_kcallocin previous code.
I have applied the following to branch ti-drivers-soc-next on [1]. Thank you!
[1/1] soc: ti: ti_sci_pm_domains: Check for null return of devm_kcalloc
commit: ba56291e297d28aa6eb82c5c1964fae2d7594746
Sidenote: [PATCH] is sufficient for v1 of the patch, it is understood to be
default indexed from 1 ;). Ofcourse, an update of the patch would have been posted as [PATCH V2] and so on..
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent up the chain during the next merge window (or sooner if it is a relevant bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
[1] git://git.kernel.org/pub/scm/linux/kernel/git/ti/linux.git
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D