From: Shawn Guo <shawn.guo@linaro.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [bug report] pinctrl: add ZTE ZX pinctrl driver support
Date: Thu, 29 Jun 2017 22:30:55 +0800 [thread overview]
Message-ID: <20170629143053.GA14078@dragon> (raw)
In-Reply-To: <20170629095152.ahkv55cjj26c3nmk@mwanda>
Hi Dan,
On Thu, Jun 29, 2017 at 12:51:52PM +0300, Dan Carpenter wrote:
> Hello Shawn Guo,
>
> The patch cbff0c4d27f4: "pinctrl: add ZTE ZX pinctrl driver support"
> from Apr 24, 2017, leads to the following static checker warning:
>
> drivers/pinctrl/zte/pinctrl-zx.c:338 zx_pinctrl_build_state()
> warn: passing devm_ allocated variable to kfree. 'functions'
I tried to see this warning with sparse, but failed. Can you please
tell how I can reproduced this static check warning?
>
> drivers/pinctrl/zte/pinctrl-zx.c
> 293
> 294 /* Build function list from pin mux functions */
> 295 functions = devm_kzalloc(&pdev->dev, info->npins * sizeof(*functions),
> ^^^^^^^^^^^^^^^^^^^^^^^^
>
> 296 GFP_KERNEL);
> 297 if (!functions)
> 298 return -ENOMEM;
> 299
> 300 nfunctions = 0;
> 301 for (i = 0; i < info->npins; i++) {
> 302 const struct pinctrl_pin_desc *pindesc = info->pins + i;
> 303 struct zx_pin_data *data = pindesc->drv_data;
> 304 struct zx_mux_desc *mux;
> 305
> 306 /* Reserved pins do not have a drv_data at all */
> 307 if (!data)
> 308 continue;
> 309
> 310 /* Loop over all muxes for the pin */
> 311 mux = data->muxes;
> 312 while (mux->name) {
> 313 struct function_desc *func = functions;
> 314
> 315 /* Search function list for given mux */
> 316 while (func->name) {
> 317 if (strcmp(mux->name, func->name) == 0) {
> 318 /* Function exists */
> 319 func->num_group_names++;
> 320 break;
> 321 }
> 322 func++;
> 323 }
> 324
> 325 if (!func->name) {
> 326 /* New function */
> 327 func->name = mux->name;
> 328 func->num_group_names = 1;
> 329 radix_tree_insert(&pctldev->pin_function_tree,
> 330 nfunctions++, func);
> 331 }
> 332
> 333 mux++;
> 334 }
> 335 }
> 336
> 337 pctldev->num_functions = nfunctions;
> 338 functions = krealloc(functions, nfunctions * sizeof(*functions),
> ^^^^^^^^^
> Not allowed.
So I guess the best fix would be changing devm_kzalloc() above to
kzalloc(), and managing the free procedure on my own, right?
Shawn
>
> 339 GFP_KERNEL);
> 340
> 341 /* Find pin groups for every single function */
> 342 for (i = 0; i < info->npins; i++) {
next prev parent reply other threads:[~2017-06-29 14:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-29 9:51 [bug report] pinctrl: add ZTE ZX pinctrl driver support Dan Carpenter
2017-06-29 14:30 ` Shawn Guo [this message]
2017-07-03 14:55 ` Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2017-06-30 7:53 Dan Carpenter
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=20170629143053.GA14078@dragon \
--to=shawn.guo@linaro.org \
--cc=dan.carpenter@oracle.com \
--cc=linux-gpio@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.