[bug report] hwmon: (ibmpowernv) Add attributes to enable/disable sensor groups

Dan Carpenter dan.carpenter at oracle.com
Tue Aug 20 22:34:07 AEST 2019


Hello Shilpasri G Bhat,

The patch e0da99123f3c: "hwmon: (ibmpowernv) Add attributes to
enable/disable sensor groups" from Jul 24, 2018, leads to the
following static checker warning:

	drivers/hwmon/ibmpowernv.c:353 init_sensor_group_data()
	warn: missing error code here? 'sgrp()' failed. 'ret' = '0'

drivers/hwmon/ibmpowernv.c
   334  static int init_sensor_group_data(struct platform_device *pdev,
   335                                    struct platform_data *pdata)
   336  {
   337          struct sensor_group_data *sgrp_data;
   338          struct device_node *groups, *sgrp;
   339          int count = 0, ret = 0;
   340          enum sensors type;
   341  
   342          groups = of_find_compatible_node(NULL, NULL, "ibm,opal-sensor-group");
   343          if (!groups)
   344                  return ret;

To me the intent would be more clear if we said "return 0;".  I look at
that I think maybe it's a bug.

   345  
   346          for_each_child_of_node(groups, sgrp) {
   347                  type = get_sensor_type(sgrp);
   348                  if (type != MAX_SENSOR_TYPE)
   349                          pdata->nr_sensor_groups++;
   350          }
   351  
   352          if (!pdata->nr_sensor_groups)
   353                  goto out;

And here?  Is this still a success path?

   354  
   355          sgrp_data = devm_kcalloc(&pdev->dev, pdata->nr_sensor_groups,
   356                                   sizeof(*sgrp_data), GFP_KERNEL);
   357          if (!sgrp_data) {
   358                  ret = -ENOMEM;
   359                  goto out;
   360          }
   361  
   362          for_each_child_of_node(groups, sgrp) {
   363                  u32 gid;
   364  
   365                  type = get_sensor_type(sgrp);

regards,
dan carpenter


More information about the Linuxppc-dev mailing list