* [PATCH v1] MIPS: ip22-gio: Add check for the return value of kzalloc()
@ 2022-03-28 8:04 QintaoShen
2022-03-29 8:35 ` Sergey Shtylyov
0 siblings, 1 reply; 3+ messages in thread
From: QintaoShen @ 2022-03-28 8:04 UTC (permalink / raw)
To: tsbogend; +Cc: linux-kernel, linux-mips, ralf, QintaoShen
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)
+ return ;
+
+ gio_dev->name = name;
gio_dev->slotno = slotno;
gio_dev->id.id = id;
gio_dev->resource.start = addr;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] MIPS: ip22-gio: Add check for the return value of kzalloc()
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
[not found] ` <16aa9238.4bf6.17fd8fe37ad.Coremail.unsimple1993@163.com>
0 siblings, 1 reply; 3+ messages in thread
From: Sergey Shtylyov @ 2022-03-29 8:35 UTC (permalink / raw)
To: QintaoShen, tsbogend; +Cc: linux-kernel, linux-mips, ralf
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] MIPS: ip22-gio: Add check for the return value of kzalloc()
[not found] ` <16aa9238.4bf6.17fd8fe37ad.Coremail.unsimple1993@163.com>
@ 2022-04-01 9:09 ` Sergey Shtylyov
0 siblings, 0 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2022-04-01 9:09 UTC (permalink / raw)
To: unSimple; +Cc: tsbogend, linux-kernel, linux-mips, ralf
On 3/30/22 7:03 AM, unSimple wrote:
> OK, here is the new version.
That won't do, your original patch description should be here.
And it should be a fresh posting with [PATCH v2] in the subject.
> Signed-off-by: QintaoShen <unSimple1993@163.com>
> ---
You need to describe what changes between v1 and v2 here...
> arch/mips/sgi-ip22/ip22-gio.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
> index dfc52f6..f94f58b 100644
> --- a/arch/mips/sgi-ip22/ip22-gio.c
> +++ b/arch/mips/sgi-ip22/ip22-gio.c
> @@ -363,6 +363,10 @@ 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);
> +
No need for empty line here.
> +if (!gio_dev)
> +return;
Hm, the tabs were there but they got eaten when I replied.
Your mail seems to be base64-encoded which I don't think is
acceptable for patches -- they should be posted as plain text.
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-01 9:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
[not found] ` <16aa9238.4bf6.17fd8fe37ad.Coremail.unsimple1993@163.com>
2022-04-01 9:09 ` Sergey Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox