[bug report] staging: mt7621-pinctrl: ralink: add pinctrl driver

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

 



Hello NeilBrown,

The patch 0317d60de869: "staging: mt7621-pinctrl: ralink: add pinctrl
driver" from Mar 15, 2018, leads to the following static checker
warning:

	drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c:144 rt2880_pinctrl_dt_node_to_map()
	info: return a literal instead of 'max_maps'

drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
   127  static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev,
   128                                  struct device_node *np_config,
   129                                  struct pinctrl_map **map,
   130                                  unsigned *num_maps)
   131  {
   132          int max_maps = 0;
   133          struct pinctrl_map *tmp;
   134          struct device_node *np;
   135  
   136          for_each_child_of_node(np_config, np) {
   137                  int ret = of_property_count_strings(np, "ralink,group");
   138  
   139                  if (ret >= 0)
   140                          max_maps += ret;
   141          }
   142  
   143          if (!max_maps)
   144                  return max_maps;
                        ^^^^^^^^^^^^^^^
This error path is buggy.  I don't know if we intended to return zero or
negative, but if we return success we should set "*num_maps = 0;" so
that it's not used uninitialized in the caller.

   145  
   146          *map = kcalloc(max_maps, sizeof(struct pinctrl_map), GFP_KERNEL);
   147          if (!*map)
   148                  return -ENOMEM;
   149  
   150          tmp = *map;
   151  
   152          for_each_child_of_node(np_config, np)
   153                  rt2880_pinctrl_dt_subnode_to_map(pctrldev, np, &tmp);
   154          *num_maps = max_maps;
   155  
   156          return 0;
   157  }

regards,
dan carpenter
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux