linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] pinctrl: sunxi: Deal with configless pins
@ 2016-11-16 12:31 Dan Carpenter
  2016-11-17 20:24 ` Maxime Ripard
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2016-11-16 12:31 UTC (permalink / raw)
  To: maxime.ripard; +Cc: linux-gpio

Hello Maxime Ripard,

The patch e11dee2e98f8: "pinctrl: sunxi: Deal with configless pins"
from Oct 20, 2016, leads to the following static checker warning:

	drivers/pinctrl/sunxi/pinctrl-sunxi.c:397 sunxi_pctrl_dt_node_to_map()
	warn: variable dereferenced before check 'map' (see line 323)

drivers/pinctrl/sunxi/pinctrl-sunxi.c
   394          *num_maps = i;
   395  
   396          /*
   397           * We know have the number of maps we need, we can resize our
   398           * map array
   399           */
   400          *map = krealloc(*map, i * sizeof(struct pinctrl_map), GFP_KERNEL);
   401          if (!map)

This should obviously be "if (*map) " here.

   402                  return -ENOMEM;
   403  
   404          return 0;
   405  
   406  err_free_map:
   407          kfree(map);

I would send a patch, but I wasn't sure about this.  Should this be
kfree(*map);?  I don't have my cross function DB built for ARM so I
don't know how this is called...  Maybe set *map to NULL as well before
returning?

   408          return ret;
   409  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] pinctrl: sunxi: Deal with configless pins
  2016-11-16 12:31 [bug report] pinctrl: sunxi: Deal with configless pins Dan Carpenter
@ 2016-11-17 20:24 ` Maxime Ripard
  2016-11-17 21:14   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Maxime Ripard @ 2016-11-17 20:24 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-gpio

[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]

Hi Dan,

On Wed, Nov 16, 2016 at 03:31:24PM +0300, Dan Carpenter wrote:
> Hello Maxime Ripard,
> 
> The patch e11dee2e98f8: "pinctrl: sunxi: Deal with configless pins"
> from Oct 20, 2016, leads to the following static checker warning:
> 
> 	drivers/pinctrl/sunxi/pinctrl-sunxi.c:397 sunxi_pctrl_dt_node_to_map()
> 	warn: variable dereferenced before check 'map' (see line 323)
> 
> drivers/pinctrl/sunxi/pinctrl-sunxi.c
>    394          *num_maps = i;
>    395  
>    396          /*
>    397           * We know have the number of maps we need, we can resize our
>    398           * map array
>    399           */
>    400          *map = krealloc(*map, i * sizeof(struct pinctrl_map), GFP_KERNEL);
>    401          if (!map)
> 
> This should obviously be "if (*map) " here.

Erm, yes, totally.

> 
>    402                  return -ENOMEM;
>    403  
>    404          return 0;
>    405  
>    406  err_free_map:
>    407          kfree(map);
> 
> I would send a patch, but I wasn't sure about this.  Should this be
> kfree(*map);?

Yes, that one too.

> I don't have my cross function DB built for ARM so I
> don't know how this is called...  Maybe set *map to NULL as well before
> returning?

And that would be even better yes :)

Will you send a patch?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] pinctrl: sunxi: Deal with configless pins
  2016-11-17 20:24 ` Maxime Ripard
@ 2016-11-17 21:14   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2016-11-17 21:14 UTC (permalink / raw)
  To: Maxime Ripard; +Cc: linux-gpio

On Thu, Nov 17, 2016 at 09:24:04PM +0100, Maxime Ripard wrote:
> Will you send a patch?

Sure.  I'll send it tomorrow.  Thanks.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-17 21:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-16 12:31 [bug report] pinctrl: sunxi: Deal with configless pins Dan Carpenter
2016-11-17 20:24 ` Maxime Ripard
2016-11-17 21:14   ` Dan Carpenter

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).