]> git.ipfire.org Git - people/ms/linux.git/commitdiff
soc: bcm: Check for NULL return of devm_kzalloc()
authorQintaoShen <unSimple1993@163.com>
Thu, 24 Mar 2022 08:35:40 +0000 (16:35 +0800)
committerFlorian Fainelli <f.fainelli@gmail.com>
Tue, 26 Apr 2022 16:12:35 +0000 (09:12 -0700)
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: 8bcac4011ebe ("soc: bcm: add PM driver for Broadcom's PMB")
Signed-off-by: QintaoShen <unSimple1993@163.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
drivers/soc/bcm/bcm63xx/bcm-pmb.c

index 7bbe46ea5f94554d65ac2e425841042af3147bfe..9407cac47fdbecf52fe7315fdd602538961fa3ee 100644 (file)
@@ -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;