From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: QintaoShen <unSimple1993@163.com>, <tsbogend@alpha.franken.de>
Cc: <linux-kernel@vger.kernel.org>, <linux-mips@vger.kernel.org>,
<ralf@linux-mips.org>
Subject: Re: [PATCH v1] MIPS: ip22-gio: Add check for the return value of kzalloc()
Date: Tue, 29 Mar 2022 11:35:01 +0300 [thread overview]
Message-ID: <6dd8bcf0-20a1-0bab-b48e-ec1bac5c15f0@omp.ru> (raw)
In-Reply-To: <1648454654-27200-1-git-send-email-unSimple1993@163.com>
Hello!
On 3/28/22 11:04 AM, QintaoShen wrote:
> Since the memory allocation function kzalloc() may return a NULL pointer,
> the use of 'gio_dev' may lead to NULL pointer dereference.
>
> So it is better to check the return value of kzalloc().
>
> Signed-off-by: QintaoShen <unSimple1993@163.com>
> ---
> arch/mips/sgi-ip22/ip22-gio.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
> index dfc52f6..df7ca21 100644
> --- a/arch/mips/sgi-ip22/ip22-gio.c
> +++ b/arch/mips/sgi-ip22/ip22-gio.c
> @@ -363,7 +363,11 @@ static void ip22_check_gio(int slotno, unsigned long addr, int irq)
> printk(KERN_INFO "GIO: slot %d : %s (id %x)\n",
> slotno, name, id);
> gio_dev = kzalloc(sizeof *gio_dev, GFP_KERNEL);
> - gio_dev->name = name;
> +
> + if (!gio_dev)
Indented too little. And indent with tabs please, not spaces.
> + return ;
No need for space before ';'.
[...]
MBR, Sergey
next prev parent reply other threads:[~2022-03-29 8:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 8:04 [PATCH v1] MIPS: ip22-gio: Add check for the return value of kzalloc() QintaoShen
2022-03-29 8:35 ` Sergey Shtylyov [this message]
[not found] ` <16aa9238.4bf6.17fd8fe37ad.Coremail.unsimple1993@163.com>
2022-04-01 9:09 ` Sergey Shtylyov
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=6dd8bcf0-20a1-0bab-b48e-ec1bac5c15f0@omp.ru \
--to=s.shtylyov@omp.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=ralf@linux-mips.org \
--cc=tsbogend@alpha.franken.de \
--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