[bug report] ARM: at91: add pinctrl support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is from an unpublished or under development Smatch check.

The patch 6732ae5cb47c: "ARM: at91: add pinctrl support" from Jul 12,
2012, leads to the following Smatch static checker warning:

	drivers/pinctrl/pinctrl-at91.c:1277 at91_pinctrl_parse_functions()
	warn: plus plus leak 'grp_index'

drivers/pinctrl/pinctrl-at91.c
    1245 static int at91_pinctrl_parse_functions(struct device_node *np,
    1246                                         struct at91_pinctrl *info, u32 index)
    1247 {
    1248         struct device_node *child;
    1249         struct at91_pmx_func *func;
    1250         struct at91_pin_group *grp;
    1251         int ret;
    1252         static u32 grp_index;
                 ^^^^^^^^^^^^^^^^^^^^
This is a static variable.

    1253         u32 i = 0;
    1254 
    1255         dev_dbg(info->dev, "parse function(%d): %pOFn\n", index, np);
    1256 
    1257         func = &info->functions[index];
    1258 
    1259         /* Initialise function */
    1260         func->name = np->name;
    1261         func->ngroups = of_get_child_count(np);
    1262         if (func->ngroups == 0) {
    1263                 dev_err(info->dev, "no groups defined\n");
    1264                 return -EINVAL;
    1265         }
    1266         func->groups = devm_kcalloc(info->dev,
    1267                         func->ngroups, sizeof(char *), GFP_KERNEL);
    1268         if (!func->groups)
    1269                 return -ENOMEM;
    1270 
    1271         for_each_child_of_node(np, child) {
    1272                 func->groups[i] = child->name;
    1273                 grp = &info->groups[grp_index++];
                                             ^^^^^^^^^^^
Incremented here.

    1274                 ret = at91_pinctrl_parse_groups(child, grp, info, i++);
    1275                 if (ret) {
    1276                         of_node_put(child);
--> 1277                         return ret;

Smatch wants it to be decremented on the error path, but actually that's
not important.  What is important is that if this hardware is probed
twice this this won't work.  (Array overflow).  I think pin controllers
normally aren't hotpluggable so it probably doesn't matter?

    1278                 }
    1279         }
    1280 
    1281         return 0;
    1282 }

regards,
dan carpenter



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux