public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: aford173@gmail.com
Cc: linux-clk@vger.kernel.org
Subject: [bug report] clk: vc5: Enable addition output configurations of the Versaclock
Date: Fri, 26 Jun 2020 13:32:18 +0300	[thread overview]
Message-ID: <20200626103218.GA314155@mwanda> (raw)

Hello Adam Ford,

The patch 260249f929e8: "clk: vc5: Enable addition output
configurations of the Versaclock" from Jun 3, 2020, leads to the
following static checker warning:

	drivers/clk/clk-versaclock5.c:795 vc5_get_output_config()
	warn: missing error code here? 'of_get_child_by_name()' failed. 'ret' = '0'

drivers/clk/clk-versaclock5.c
   784  static int vc5_get_output_config(struct i2c_client *client,
   785                                   struct vc5_hw_data *clk_out)
   786  {
   787          struct device_node *np_output;
   788          char *child_name;
   789          int ret = 0;
   790  
   791          child_name = kasprintf(GFP_KERNEL, "OUT%d", clk_out->num + 1);
                ^^^^^^^^^^
No check for NULL which will lead to an Oops on the next line.

   792          np_output = of_get_child_by_name(client->dev.of_node, child_name);
                                                                      ^^^^^^^^^^
Dereferenced without checking inside function.

   793          kfree(child_name);
   794          if (!np_output)
   795                  goto output_done;
                        ^^^^^^^^^^^^^^^^^
Why not just "return 0;" so that it's obvious this path is a success
path.  :/  Do nothing gotos have a typical forgot to set the error
code bug but direct returns don't suffer from this problem.

People think that do nothing gotos will force future developers think
about error handling but this is not supported by data.  My experience
is that nothing can force people to think about error handling.

   796  
   797          ret = vc5_update_mode(np_output, clk_out);
   798          if (ret)
   799                  goto output_error;
   800  
   801          ret = vc5_update_power(np_output, clk_out);
   802          if (ret)
   803                  goto output_error;
   804  
   805          ret = vc5_update_slew(np_output, clk_out);
   806  
   807  output_error:
   808          if (ret) {
   809                  dev_err(&client->dev,
   810                          "Invalid clock output configuration OUT%d\n",
   811                          clk_out->num + 1);
   812          }
   813  
   814          of_node_put(np_output);
   815  
   816  output_done:
   817          return ret;
   818  }

regards,
dan carpenter

             reply	other threads:[~2020-06-26 10:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26 10:32 Dan Carpenter [this message]
2020-06-26 22:11 ` [bug report] clk: vc5: Enable addition output configurations of the Versaclock Adam Ford

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=20200626103218.GA314155@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=aford173@gmail.com \
    --cc=linux-clk@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox