pinctrl: sunxi: Deal with configless pins
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
Hi Dan,
Quoted 18 lines · Dan Carpenter
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:397sunxi_pctrl_dt_node_to_map()
warn: variable dereferenced before check 'map' (see line 323)
drivers/pinctrl/sunxi/pinctrl-sunxi.c394 *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)
Quoted 1 line
This should obviously be "if (*map) " here.
Erm, yes, totally.
Quoted 10 lines
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.
Quoted 3 lines
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
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Quoted 1 line · Maxime Ripard
Will you send a patch?
Sure. I'll send it tomorrow. Thanks.
regards,
dan carpenter