From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: QintaoShen <unSimple1993@163.com>, <f.fainelli@gmail.com>
Cc: <bcm-kernel-feedback-list@broadcom.com>,
<linux-mips@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] soc: bcm: Check for NULL return of devm_kzalloc()
Date: Fri, 25 Mar 2022 12:02:28 +0300 [thread overview]
Message-ID: <0f5e77e9-3c2c-396d-636b-1b7153007fe5@omp.ru> (raw)
In-Reply-To: <1648110940-4684-1-git-send-email-unSimple1993@163.com>
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@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);
Please keep an empty line after declaration.
> + if (!pd)
> + return -ENOMEM;
>
> pd->pmb = pmb;
> pd->data = e;
MBR, Sergey
next prev parent reply other threads:[~2022-03-25 9:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 8:35 [PATCH v1] soc: bcm: Check for NULL return of devm_kzalloc() QintaoShen
2022-03-24 17:04 ` Florian Fainelli
2022-03-25 9:02 ` Sergey Shtylyov [this message]
2022-03-28 4:13 ` QintaoShen
2022-04-19 18:33 ` Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0f5e77e9-3c2c-396d-636b-1b7153007fe5@omp.ru \
--to=s.shtylyov@omp.ru \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=unSimple1993@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox