linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.ibm.com>
To: Guenter Roeck <linux@roeck-us.net>,
	Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [bug report] hwmon: (pmbus/ibm-cffps) Add new manufacturer debugfs entries
Date: Tue, 7 Jan 2020 09:08:36 -0600	[thread overview]
Message-ID: <4fd3f6eb-e3b1-352f-40cd-668e334eb79f@linux.ibm.com> (raw)
In-Reply-To: <a9d596c2-bbbf-02e0-80a0-50cecf6a0665@roeck-us.net>


On 1/7/20 7:53 AM, Guenter Roeck wrote:
> 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).


I'll make the change.


Good catch Dan, thanks!

Eddie


>
> 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
>>
>

      reply	other threads:[~2020-01-07 15:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 13:32 [bug report] hwmon: (pmbus/ibm-cffps) Add new manufacturer debugfs entries Dan Carpenter
2020-01-07 13:53 ` Guenter Roeck
2020-01-07 15:08   ` Eddie James [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4fd3f6eb-e3b1-352f-40cd-668e334eb79f@linux.ibm.com \
    --to=eajames@linux.ibm.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).