diff mbox series

clk: zynq: do not allow kmalloc failure

Message ID 1542795390-16221-1-git-send-email-hofrat@osadl.org (mailing list archive)
State New, archived
Headers show
Series clk: zynq: do not allow kmalloc failure | expand

Commit Message

Nicholas Mc Guire Nov. 21, 2018, 10:16 a.m. UTC
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(-)

Comments

Michal Simek Nov. 21, 2018, 12:01 p.m. UTC | #1
On 21. 11. 18 11:16, Nicholas Mc Guire wrote:
>  The kmalloc here is small (< 16 bytes) and occurs during initialization

no reason for space in front of "The"

> 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

ditto.

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

I have no problem with the patch but things below your SoB shouldn't
land in the git history.

When this is fixed feel free to add my
Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal
diff mbox series

Patch

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;