linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: t-kristo@ti.com
Cc: linux-clk@vger.kernel.org
Subject: [bug report] clk: ti: divider: add driver internal API for parsing divider data
Date: Mon, 17 Dec 2018 17:45:53 +0300	[thread overview]
Message-ID: <20181217144553.GA11066@kadam> (raw)

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;

             reply	other threads:[~2018-12-17 14:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-17 14:45 Dan Carpenter [this message]
2019-01-09 19:45 ` [bug report] clk: ti: divider: add driver internal API for parsing divider data 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
  -- strict thread matches above, loose matches on Subject: below --
2017-04-11 22:16 [bug report] clk: ti: divider: add driver internal API for parsing divider data Dan Carpenter
2017-04-12  7:20 ` Tero Kristo
2017-04-12 16:38   ` Stephen Boyd

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=20181217144553.GA11066@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=t-kristo@ti.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 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).