linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: zynq: do not allow kmalloc failure
@ 2018-11-21 10:16 Nicholas Mc Guire
  2018-11-21 12:01 ` Michal Simek
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2018-11-21 10:16 UTC (permalink / raw)
  To: Michael Turquette
  Cc: Stephen Boyd, Michal Simek, Rob Herring, linux-clk,
	linux-arm-kernel, linux-kernel, Nicholas Mc Guire

 The kmalloc here is small (< 16 bytes) and occurs during initialization
during system startup here (can not be built as module) thus if this
kmalloc failed it is an indication of something more serious going on
and it is fine to hang the system here rather than cause some harder
to understand error by dereferencing NULL.

 Explicitly checking would not make that much sense here as the only
possible reaction would be would BUG() here anyway.

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

Problem located with experimental coccinelle script

Patch was compile tested with: multi_v7_defconfig (implies
CONFIG_ARCH_ZYNQ=y)

Patch is against 4.20-rc3 (localversion-next is next-20181121)

---
 drivers/clk/zynq/clkc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index d7b53ac..014d4a4 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -440,7 +440,7 @@ static void __init zynq_clk_setup(struct device_node *np)
 			SLCR_GEM1_CLK_CTRL, 0, 0, &gem1clk_lock);
 
 	tmp = strlen("mio_clk_00x");
-	clk_name = kmalloc(tmp, GFP_KERNEL);
+	clk_name = kmalloc(tmp, GFP_KERNEL | __GFP_NOFAIL);
 	for (i = 0; i < NUM_MIO_PINS; i++) {
 		int idx;
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-21 12:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-21 10:16 [PATCH] clk: zynq: do not allow kmalloc failure Nicholas Mc Guire
2018-11-21 12:01 ` Michal Simek

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).