From: Dan Carpenter <dan.carpenter@oracle.com>
To: heikki.krogerus@linux.intel.com
Cc: linux-wireless@vger.kernel.org
Subject: re: net: rfkill: gpio: convert to descriptor-based GPIO interface
Date: Wed, 8 Jan 2014 18:28:38 +0300 [thread overview]
Message-ID: <20140108152837.GA3017@elgon.mountain> (raw)
Hello Heikki Krogerus,
This is a semi-automatic email about new static checker warnings.
The patch 2111cad655e3: "net: rfkill: gpio: convert to
descriptor-based GPIO interface" from Nov 26, 2013, leads to the
following Smatch complaint:
net/rfkill/rfkill-gpio.c:144 rfkill_gpio_probe()
warn: variable dereferenced before check 'rfkill->name' (see line 144)
net/rfkill/rfkill-gpio.c
111 len = strlen(rfkill->name);
^^^^^^^^^^^^
Dereference.
112 rfkill->reset_name = devm_kzalloc(&pdev->dev, len + 7, GFP_KERNEL);
113 if (!rfkill->reset_name)
114 return -ENOMEM;
115
116 rfkill->shutdown_name = devm_kzalloc(&pdev->dev, len + 10, GFP_KERNEL);
117 if (!rfkill->shutdown_name)
118 return -ENOMEM;
119
120 snprintf(rfkill->reset_name, len + 6 , "%s_reset", rfkill->name);
121 snprintf(rfkill->shutdown_name, len + 9, "%s_shutdown", rfkill->name);
122
123 rfkill->clk = devm_clk_get(&pdev->dev, clk_name);
124
125 gpio = devm_gpiod_get_index(&pdev->dev, rfkill->reset_name, 0);
126 if (!IS_ERR(gpio)) {
127 ret = gpiod_direction_output(gpio, 0);
128 if (ret)
129 return ret;
130 rfkill->reset_gpio = gpio;
131 }
132
133 gpio = devm_gpiod_get_index(&pdev->dev, rfkill->shutdown_name, 1);
134 if (!IS_ERR(gpio)) {
135 ret = gpiod_direction_output(gpio, 0);
136 if (ret)
137 return ret;
138 rfkill->shutdown_gpio = gpio;
139 }
140
141 /* Make sure at-least one of the GPIO is defined and that
142 * a name is specified for this instance
143 */
144 if ((!rfkill->reset_gpio && !rfkill->shutdown_gpio) || !rfkill->name) {
^^^^^^^^^^^^
The check was originally before the dereference, but the patch moves it
after the dereference.
145 dev_err(&pdev->dev, "invalid platform data\n");
146 return -EINVAL;
regards,
dan carpenter
next reply other threads:[~2014-01-08 15:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-08 15:28 Dan Carpenter [this message]
2014-01-14 14:41 ` net: rfkill: gpio: convert to descriptor-based GPIO interface Heikki Krogerus
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=20140108152837.GA3017@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-wireless@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;
as well as URLs for NNTP newsgroup(s).