Commit b4bd2aaf authored by QintaoShen's avatar QintaoShen Committed by Florian Fainelli
Browse files

soc: bcm: Check for NULL return of devm_kzalloc()



As the potential failure of allocation, devm_kzalloc() may return NULL.  Then
the 'pd->pmb' and the follow lines of code may bring null pointer dereference.

Therefore, it is better to check the return value of devm_kzalloc() to avoid
this confusion.

Fixes: 8bcac401 ("soc: bcm: add PM driver for Broadcom's PMB")
Signed-off-by: default avatarQintaoShen <unSimple1993@163.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
parent 31231092
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -312,6 +312,9 @@ static int bcm_pmb_probe(struct platform_device *pdev)
	for (e = table; e->name; e++) {
		struct bcm_pmb_pm_domain *pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);

		if (!pd)
			return -ENOMEM;

		pd->pmb = pmb;
		pd->data = e;
		pd->genpd.name = e->name;