lkml.org 
[lkml]   [2022]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1] soc: bcm: Check for NULL return of devm_kzalloc()
Date
As the potential failuer 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.

Signed-off-by: QintaoShen <unSimple1993@163.com>
---
drivers/soc/bcm/bcm63xx/bcm-pmb.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/soc/bcm/bcm63xx/bcm-pmb.c b/drivers/soc/bcm/bcm63xx/bcm-pmb.c
index 7bbe46e..55bf389 100644
--- a/drivers/soc/bcm/bcm63xx/bcm-pmb.c
+++ b/drivers/soc/bcm/bcm63xx/bcm-pmb.c
@@ -311,6 +311,8 @@ 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;
--
2.7.4
\
 
 \ /
  Last update: 2022-03-24 09:36    [W:0.052 / U:1.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site