All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <hofrat@osadl.org>
To: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Gregory Clement <gregory.clement@bootlin.com>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Nicholas Mc Guire <hofrat@osadl.org>
Subject: [PATCH 1/3 RFC] ARM: mvebu: at least warn on kzalloc failure
Date: Sun, 14 Apr 2019 06:49:49 +0200	[thread overview]
Message-ID: <1555217391-3552-1-git-send-email-hofrat@osadl.org> (raw)

Although it is very unlikely that the allocation during init would
fail any such failure should point to the original cause rather
than waiting for a null-pointer dereference to splat.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

Problem located with experimental coccinelle script

While this will not really help much - but kzalloc failures should not
go unhandled. 

Patch was compile-tested: mvebu_v7_defconfig (implies MACH_MVEBU_ANY=y)
(with some unrelated sparse warnings about missing syscalls)

Patch is against 5.1-rc4 (localversion-next is 20190412)

 arch/arm/mach-mvebu/board-v7.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
index 0b10acd..37f8cb6 100644
--- a/arch/arm/mach-mvebu/board-v7.c
+++ b/arch/arm/mach-mvebu/board-v7.c
@@ -128,6 +128,7 @@ static void __init i2c_quirk(void)
 		struct property *new_compat;
 
 		new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL);
+		WARN_ON(!new_compat);
 
 		new_compat->name = kstrdup("compatible", GFP_KERNEL);
 		new_compat->length = sizeof("marvell,mv78230-a0-i2c");
-- 
2.1.4


WARNING: multiple messages have this Message-ID (diff)
From: Nicholas Mc Guire <hofrat@osadl.org>
To: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Gregory Clement <gregory.clement@bootlin.com>,
	linux-kernel@vger.kernel.org,
	Russell King <linux@armlinux.org.uk>,
	Nicholas Mc Guire <hofrat@osadl.org>,
	linux-arm-kernel@lists.infradead.org,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Subject: [PATCH 1/3 RFC] ARM: mvebu: at least warn on kzalloc failure
Date: Sun, 14 Apr 2019 06:49:49 +0200	[thread overview]
Message-ID: <1555217391-3552-1-git-send-email-hofrat@osadl.org> (raw)

Although it is very unlikely that the allocation during init would
fail any such failure should point to the original cause rather
than waiting for a null-pointer dereference to splat.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

Problem located with experimental coccinelle script

While this will not really help much - but kzalloc failures should not
go unhandled. 

Patch was compile-tested: mvebu_v7_defconfig (implies MACH_MVEBU_ANY=y)
(with some unrelated sparse warnings about missing syscalls)

Patch is against 5.1-rc4 (localversion-next is 20190412)

 arch/arm/mach-mvebu/board-v7.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
index 0b10acd..37f8cb6 100644
--- a/arch/arm/mach-mvebu/board-v7.c
+++ b/arch/arm/mach-mvebu/board-v7.c
@@ -128,6 +128,7 @@ static void __init i2c_quirk(void)
 		struct property *new_compat;
 
 		new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL);
+		WARN_ON(!new_compat);
 
 		new_compat->name = kstrdup("compatible", GFP_KERNEL);
 		new_compat->length = sizeof("marvell,mv78230-a0-i2c");
-- 
2.1.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2019-04-14  4:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-14  4:49 Nicholas Mc Guire [this message]
2019-04-14  4:49 ` [PATCH 1/3 RFC] ARM: mvebu: at least warn on kzalloc failure Nicholas Mc Guire
2019-04-14  4:49 ` [PATCH 2/3] ARM: mvebu: drop return from void function Nicholas Mc Guire
2019-04-14  4:49   ` Nicholas Mc Guire
2019-04-21 17:23   ` Gregory CLEMENT
2019-04-21 17:23     ` Gregory CLEMENT
2019-04-14  4:49 ` [PATCH 3/3] ARM: mvebu: add SPDX license identifier Nicholas Mc Guire
2019-04-14  4:49   ` Nicholas Mc Guire
2019-04-14 16:22   ` Andrew Lunn
2019-04-14 16:22     ` Andrew Lunn
2019-04-14 23:22     ` Nicholas Mc Guire
2019-04-14 23:22       ` Nicholas Mc Guire
2019-04-14 17:26 ` [PATCH 1/3 RFC] ARM: mvebu: at least warn on kzalloc failure Russell King - ARM Linux admin
2019-04-14 17:26   ` Russell King - ARM Linux admin
2019-04-14 23:24   ` Nicholas Mc Guire
2019-04-14 23:24     ` Nicholas Mc Guire

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=1555217391-3552-1-git-send-email-hofrat@osadl.org \
    --to=hofrat@osadl.org \
    --cc=andrew@lunn.ch \
    --cc=gregory.clement@bootlin.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=sebastian.hesselbarth@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.