linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] clk: ti: divider: add driver internal API for parsing divider data
@ 2018-12-17 14:45 Dan Carpenter
  2019-01-09 19:45 ` Stephen Boyd
  0 siblings, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2018-12-17 14:45 UTC (permalink / raw)
  To: t-kristo; +Cc: linux-clk

Hello Tero Kristo,

The patch 4f6be5655dc9: "clk: ti: divider: add driver internal API
for parsing divider data" from Feb 9, 2017, leads to the following
static checker warning:

	drivers/clk/ti/divider.c:491 ti_clk_register_divider()
	warn: 'table' isn't an ERR_PTR

drivers/clk/ti/divider.c
   468  struct clk *ti_clk_register_divider(struct ti_clk *setup)
   469  {
   470          struct ti_clk_divider *div = setup->data;
   471          struct clk_omap_reg reg = {
   472                  .index = div->module,
   473                  .offset = div->reg,
   474          };
   475          u8 width;
   476          u32 flags = 0;
   477          u8 div_flags = 0;
   478          const struct clk_div_table *table;
   479          struct clk *clk;
   480  
   481          if (div->flags & CLKF_INDEX_STARTS_AT_ONE)
   482                  div_flags |= CLK_DIVIDER_ONE_BASED;
   483  
   484          if (div->flags & CLKF_INDEX_POWER_OF_TWO)
   485                  div_flags |= CLK_DIVIDER_POWER_OF_TWO;
   486  
   487          if (div->flags & CLKF_SET_RATE_PARENT)
   488                  flags |= CLK_SET_RATE_PARENT;
   489  
   490          table = _get_div_table_from_setup(div, &width);
   491          if (IS_ERR(table))
                           ^^^^^

NULL is actually allowed here so we can't just change this to a check
for NULL.  Prior to this commit if the:

	tmp = kcalloc(valid_div + 1, sizeof(*tmp), GFP_KERNEL);

allocation failed then table was PTR_ERR(-ENOMEM).  I guess we should
change it back.  We could probably do sothing like the diff below?

   492                  return (struct clk *)table;
   493  
   494          clk = _register_divider(NULL, setup->name, div->parent,
   495                                  flags, &reg, div->bit_shift,
   496                                  width, -EINVAL, div_flags, table);
   497  
   498          if (IS_ERR(clk))
   499                  kfree(table);
   500  
   501          return clk;
   502  }


diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c
index 8d77090ad94a..c4335eba2b2e 100644
--- a/drivers/clk/ti/divider.c
+++ b/drivers/clk/ti/divider.c
@@ -403,8 +403,10 @@ int ti_clk_parse_divider_data(int *div_table, int num_dividers, int max_div,
 	num_dividers = i;
 
 	tmp = kcalloc(valid_div + 1, sizeof(*tmp), GFP_KERNEL);
-	if (!tmp)
+	if (!tmp) {
+		*table = PTR_ERR(-ENOMEM);
 		return -ENOMEM;
+	}
 
 	valid_div = 0;
 	*width = 0;

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

end of thread, other threads:[~2019-01-24 20:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17 14:45 [bug report] clk: ti: divider: add driver internal API for parsing divider data Dan Carpenter
2019-01-09 19:45 ` Stephen Boyd
2019-01-15  7:01   ` [PATCH] clk: ti: Fix error handling in ti_clk_parse_divider_data() Dan Carpenter
2019-01-15  8:36     ` Tero Kristo
2019-01-15 13:21     ` kbuild test robot
2019-01-15 13:42     ` Dan Carpenter
2019-01-15 13:53     ` kbuild test robot
2019-01-15 19:46     ` [PATCH v2] " Dan Carpenter
2019-01-24 19:24       ` Stephen Boyd
2019-01-24 19:50         ` Tero Kristo

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