linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* question about drivers/pinctrl/pinctrl-at91.c
@ 2012-12-08 15:52 Julia Lawall
  2012-12-11  8:51 ` Linus Walleij
  2012-12-11  9:06 ` Grant Likely
  0 siblings, 2 replies; 6+ messages in thread
From: Julia Lawall @ 2012-12-08 15:52 UTC (permalink / raw)
  To: linux-arm-kernel

The function at91_dt_node_to_map in drivers/pinctrl/pinctrl-at91.c 
contains the following code:

        new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num, GFP_KERNEL);
         if (!new_map)
                 return -ENOMEM;

         *map = new_map;
         *num_maps = map_num;

         /* create mux map */
         parent = of_get_parent(np);
         if (!parent) {
                 kfree(new_map);
                 return -EINVAL;
         }

This is clearly not correct, because the combination of devm_kzalloc and 
kfree risks creating a double free.  But I am not sure how best to fix it. 
Is the data structure intended to normally exist until the driver's remove 
function is called?  If so, perhaps the devm_kzalloc is OK.  If I just 
remove the kfree, then the structure will persist until the remove 
function is called, even though there was an error, which is perhaps not 
good.  So I could change the kfree to devm_kfree?

thanks,
julia

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

end of thread, other threads:[~2012-12-11  9:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-08 15:52 question about drivers/pinctrl/pinctrl-at91.c Julia Lawall
2012-12-11  8:51 ` Linus Walleij
2012-12-11  9:04   ` Julia Lawall
2012-12-11  9:08     ` Linus Walleij
2012-12-11  9:59       ` Julia Lawall
2012-12-11  9:06 ` Grant Likely

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