lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 28 Mar 2022 12:13:40 +0800
From:   QintaoShen <unSimple1993@....com>
To:     Sergey Shtylyov <s.shtylyov@....ru>
Cc:     bcm-kernel-feedback-list@...adcom.com, f.fainelli@...il.com,
        linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] soc: bcm: Check for NULL return of devm_kzalloc()

OK. Here is the new version.

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

diff --git a/drivers/soc/bcm/bcm63xx/bcm-pmb.c 
b/drivers/soc/bcm/bcm63xx/bcm-pmb.c
index 7bbe46e..cc20ffb 100644
--- a/drivers/soc/bcm/bcm63xx/bcm-pmb.c
+++ b/drivers/soc/bcm/bcm63xx/bcm-pmb.c
@@ -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;
-- 
2.7.4

在 2022/3/25 下午5:02, Sergey Shtylyov 写道:
> Hello!
>
>     s/return/result/ in the subject.
>
> On 3/24/22 11:35 AM, QintaoShen wrote:
>
>> 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.
>     Following.
>
>> Therefore, it is better to check the return value of devm_kzalloc() to avoid this confusion.
>>
>> Signed-off-by: QintaoShen <unSimple1993@....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);
>     Please keep an empty line after declaration.
>
>> +		if (!pd)
>> +			return -ENOMEM;
>>   
>>   		pd->pmb = pmb;
>>   		pd->data = e;
> MBR, Sergey

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ