* [PATCH 1/3 RFC] ARM: mvebu: at least warn on kzalloc failure @ 2019-04-14 4:49 Nicholas Mc Guire 2019-04-14 4:49 ` [PATCH 2/3] ARM: mvebu: drop return from void function Nicholas Mc Guire ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Nicholas Mc Guire @ 2019-04-14 4:49 UTC (permalink / raw) To: Jason Cooper Cc: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth, Russell King, linux-arm-kernel, linux-kernel, Nicholas Mc Guire 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] ARM: mvebu: drop return from void function 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 ` Nicholas Mc Guire 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 17:26 ` [PATCH 1/3 RFC] ARM: mvebu: at least warn on kzalloc failure Russell King - ARM Linux admin 2 siblings, 1 reply; 8+ messages in thread From: Nicholas Mc Guire @ 2019-04-14 4:49 UTC (permalink / raw) To: Jason Cooper Cc: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth, Russell King, linux-arm-kernel, linux-kernel, Nicholas Mc Guire The return statement is unnecessary here - so drop it. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> --- Problem reported by checkpatch WARNING: void function return statements are not generally useful #141: FILE: arch/arm/mach-mvebu/board-v7.c:141: + return; +} 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 deletion(-) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index 37f8cb6..28fd256 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -137,7 +137,6 @@ static void __init i2c_quirk(void) of_update_property(np, new_compat); } - return; } static void __init mvebu_dt_init(void) -- 2.1.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] ARM: mvebu: drop return from void function 2019-04-14 4:49 ` [PATCH 2/3] ARM: mvebu: drop return from void function Nicholas Mc Guire @ 2019-04-21 17:23 ` Gregory CLEMENT 0 siblings, 0 replies; 8+ messages in thread From: Gregory CLEMENT @ 2019-04-21 17:23 UTC (permalink / raw) To: Nicholas Mc Guire, Jason Cooper Cc: Andrew Lunn, Sebastian Hesselbarth, Russell King, linux-arm-kernel, linux-kernel, Nicholas Mc Guire Hi Nicholas, > The return statement is unnecessary here - so drop it. > > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Applied on mvebu/arm Thanks, Gregory > --- > > Problem reported by checkpatch > > WARNING: void function return statements are not generally useful > #141: FILE: arch/arm/mach-mvebu/board-v7.c:141: > + return; > +} > > 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 deletion(-) > > diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c > index 37f8cb6..28fd256 100644 > --- a/arch/arm/mach-mvebu/board-v7.c > +++ b/arch/arm/mach-mvebu/board-v7.c > @@ -137,7 +137,6 @@ static void __init i2c_quirk(void) > > of_update_property(np, new_compat); > } > - return; > } > > static void __init mvebu_dt_init(void) > -- > 2.1.4 > -- Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] ARM: mvebu: add SPDX license identifier 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-14 16:22 ` Andrew Lunn 2019-04-14 17:26 ` [PATCH 1/3 RFC] ARM: mvebu: at least warn on kzalloc failure Russell King - ARM Linux admin 2 siblings, 1 reply; 8+ messages in thread From: Nicholas Mc Guire @ 2019-04-14 4:49 UTC (permalink / raw) To: Jason Cooper Cc: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth, Russell King, linux-arm-kernel, linux-kernel, Nicholas Mc Guire The license is clearly identified as GPL V2 - so just add in the appropriate SPDX license identifier. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> --- Problem reported by checkpatch WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 #1: FILE: arch/arm/mach-mvebu/board-v7.c:1: +/* 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 28fd256..0e021c9 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Device Tree support for Armada 370 and XP platforms. * -- 2.1.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] ARM: mvebu: add SPDX license identifier 2019-04-14 4:49 ` [PATCH 3/3] ARM: mvebu: add SPDX license identifier Nicholas Mc Guire @ 2019-04-14 16:22 ` Andrew Lunn 2019-04-14 23:22 ` Nicholas Mc Guire 0 siblings, 1 reply; 8+ messages in thread From: Andrew Lunn @ 2019-04-14 16:22 UTC (permalink / raw) To: Nicholas Mc Guire Cc: Jason Cooper, Gregory Clement, Sebastian Hesselbarth, Russell King, linux-arm-kernel, linux-kernel On Sun, Apr 14, 2019 at 06:49:51AM +0200, Nicholas Mc Guire wrote: > The license is clearly identified as GPL V2 - so just add in the > appropriate SPDX license identifier. > > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Hi Nicholas Adding a SPDX line makes the license text redundant, so you should remove it in the same patch as adding the SPDX line. Andrew ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] ARM: mvebu: add SPDX license identifier 2019-04-14 16:22 ` Andrew Lunn @ 2019-04-14 23:22 ` Nicholas Mc Guire 0 siblings, 0 replies; 8+ messages in thread From: Nicholas Mc Guire @ 2019-04-14 23:22 UTC (permalink / raw) To: Andrew Lunn Cc: Nicholas Mc Guire, Jason Cooper, Gregory Clement, Sebastian Hesselbarth, Russell King, linux-arm-kernel, linux-kernel On Sun, Apr 14, 2019 at 06:22:10PM +0200, Andrew Lunn wrote: > On Sun, Apr 14, 2019 at 06:49:51AM +0200, Nicholas Mc Guire wrote: > > The license is clearly identified as GPL V2 - so just add in the > > appropriate SPDX license identifier. > > > > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> > > Hi Nicholas > > Adding a SPDX line makes the license text redundant, so you should > remove it in the same patch as adding the SPDX line. > So remove that first line from this paragraph * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. reducing it to: * This program is licensed "as is" without any warranty of any kind, * whether express or implied. Is that what you are proposing ? The GPL does state that there is no warranty but using a different wording that may not be legally equivalent. thx! hofrat ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3 RFC] ARM: mvebu: at least warn on kzalloc failure 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 ` [PATCH 3/3] ARM: mvebu: add SPDX license identifier Nicholas Mc Guire @ 2019-04-14 17:26 ` Russell King - ARM Linux admin 2019-04-14 23:24 ` Nicholas Mc Guire 2 siblings, 1 reply; 8+ messages in thread From: Russell King - ARM Linux admin @ 2019-04-14 17:26 UTC (permalink / raw) To: Nicholas Mc Guire Cc: Jason Cooper, Andrew Lunn, Gregory Clement, Sebastian Hesselbarth, linux-arm-kernel, linux-kernel On Sun, Apr 14, 2019 at 06:49:49AM +0200, Nicholas Mc Guire wrote: > 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. Sorry, no, not like this. With this patch, rather than getting an oops and a stacktrace which people can capture and email, we instead end up getting a warning line, a stack trace, followed by an oops containing another stack trace. We _already_ have problems getting people to send us kernel message debug information without editing out what they deem to be "unnecessary verbage", like all those numbers and function names that comprise a stack trace. We don't need yet more of that stuff, especially when it is redundant. So, I think throwing WARN_ON() at this case is way too excessive, and will only have a detrimental effect on the reports we receive - and that is extremely important. IMHO, A better solution would be to just print a warning, rather than causing the kernel to print several kB of needless messages. if (!new_compat) pr_err("new_compat allocation failure in %s()\n", __func__); > > 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 > > -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3 RFC] ARM: mvebu: at least warn on kzalloc failure 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 23:24 ` Nicholas Mc Guire 0 siblings, 0 replies; 8+ messages in thread From: Nicholas Mc Guire @ 2019-04-14 23:24 UTC (permalink / raw) To: Russell King - ARM Linux admin Cc: Nicholas Mc Guire, Jason Cooper, Andrew Lunn, Gregory Clement, Sebastian Hesselbarth, linux-arm-kernel, linux-kernel On Sun, Apr 14, 2019 at 06:26:02PM +0100, Russell King - ARM Linux admin wrote: > On Sun, Apr 14, 2019 at 06:49:49AM +0200, Nicholas Mc Guire wrote: > > 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. > > Sorry, no, not like this. > ok - well I wsa not sure about it either - it just seems wrong to leave a possible allocation failure without any response. The issue of generating excessive outout make sense - so will fix it up to a pr_err() and resend. thx! hofrat > With this patch, rather than getting an oops and a stacktrace which > people can capture and email, we instead end up getting a warning > line, a stack trace, followed by an oops containing another stack > trace. > > We _already_ have problems getting people to send us kernel message > debug information without editing out what they deem to be "unnecessary > verbage", like all those numbers and function names that comprise a > stack trace. We don't need yet more of that stuff, especially when it > is redundant. > > So, I think throwing WARN_ON() at this case is way too excessive, and > will only have a detrimental effect on the reports we receive - and > that is extremely important. > > IMHO, A better solution would be to just print a warning, rather than > causing the kernel to print several kB of needless messages. > > if (!new_compat) > pr_err("new_compat allocation failure in %s()\n", > __func__); > > > > > 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 > > > > > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up > According to speedtest.net: 11.9Mbps down 500kbps up ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-04-21 17:23 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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-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 16:22 ` Andrew Lunn 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 23:24 ` Nicholas Mc Guire
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).