Re: [bug report] hwmon: (pmbus/ibm-cffps) Add new manufacturer debugfs entries

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

 



On 1/7/20 5:32 AM, Dan Carpenter wrote:
Hello Eddie James,

The patch bb3c0a27ed1d: "hwmon: (pmbus/ibm-cffps) Add new
manufacturer debugfs entries" from Dec 19, 2019, leads to the
following static checker warning:

	drivers/hwmon/pmbus/ibm-cffps.c:257 ibm_cffps_debugfs_write()
	error: uninitialized symbol 'data'.

drivers/hwmon/pmbus/ibm-cffps.c
    238  static ssize_t ibm_cffps_debugfs_write(struct file *file,
    239                                         const char __user *buf, size_t count,
    240                                         loff_t *ppos)
    241  {
    242          u8 data;
    243          ssize_t rc;
    244          int *idxp = file->private_data;
    245          int idx = *idxp;
    246          struct ibm_cffps *psu = to_psu(idxp, idx);
    247
    248          switch (idx) {
    249          case CFFPS_DEBUGFS_ON_OFF_CONFIG:
    250                  pmbus_set_page(psu->client, 0);
    251
    252                  rc = simple_write_to_buffer(&data, 1, ppos, buf, count);
                                                     ^^^^^^^^^^^^^^
If "ppos >= 1" then "data" isn't initialized but "rc" is zero.


If rc == 0 (ie if no data was read) we should probably bail out here (either return
an error or 0).

Guenter

    253                  if (rc < 0)
    254                          return rc;
    255
    256                  rc = i2c_smbus_write_byte_data(psu->client,
    257                                                 PMBUS_ON_OFF_CONFIG, data);
    258                  if (rc)
    259                          return rc;
    260
    261                  rc = 1;
    262                  break;
    263          default:
    264                  return -EINVAL;
    265          }
    266
    267          return rc;
    268  }

regards,
dan carpenter





[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux