All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [bug report] bus: ti-sysc: Add handling for clkctrl opt clocks
Date: Thu, 17 May 2018 12:45:14 +0000	[thread overview]
Message-ID: <20180517124514.GA9149@mwanda> (raw)

Hello Tony Lindgren,

The patch 09dfe5810762: "bus: ti-sysc: Add handling for clkctrl opt
clocks" from Apr 16, 2018, leads to the following static checker
warning:

	drivers/bus/ti-sysc.c:131 sysc_get_one_clock()
	error: buffer overflow 'clock_names' 2 <= 9

drivers/bus/ti-sysc.c
   120  static int sysc_get_one_clock(struct sysc *ddata, const char *name)
   121  {
   122          int error, i, index = -ENODEV;
   123  
   124          if (!strncmp(clock_names[SYSC_FCK], name, 3))
   125                  index = SYSC_FCK;
   126          else if (!strncmp(clock_names[SYSC_ICK], name, 3))
   127                  index = SYSC_ICK;
   128  
   129          if (index < 0) {
   130                  for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) {
   131                          if (!clock_names[i]) {
                                     ^^^^^^^^^^^^^^
This isn't right.  The clock_names[] array only has the two elements...
Probably it should be testing ddate->clocks[i]?

   132                                  index = i;
   133                                  break;
   134                          }
   135                  }
   136          }
   137  
   138          if (index < 0) {
   139                  dev_err(ddata->dev, "clock %s not added\n", name);
   140                  return index;
   141          }
   142  
   143          ddata->clocks[index] = devm_clk_get(ddata->dev, name);
   144          if (IS_ERR(ddata->clocks[index])) {
   145                  if (PTR_ERR(ddata->clocks[index]) = -ENOENT)
   146                          return 0;
   147  
   148                  dev_err(ddata->dev, "clock get error for %s: %li\n",
   149                          name, PTR_ERR(ddata->clocks[index]));
   150  

Should we set ddata->clocks[index] = NULL on this path?

   151                  return PTR_ERR(ddata->clocks[index]);
   152          }


regards,
dan carpenter

             reply	other threads:[~2018-05-17 12:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17 12:45 Dan Carpenter [this message]
2018-05-17 14:03 ` [bug report] bus: ti-sysc: Add handling for clkctrl opt clocks Tony Lindgren
2018-05-17 22:03 ` Tony Lindgren

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=20180517124514.GA9149@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.