Re: [bug report] hwmon: (nct7802) Use multi-byte regmap operations

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

 



On 7/31/24 10:42, Guenter Roeck wrote:
On 7/31/24 10:31, Dan Carpenter wrote:
Hello Guenter Roeck,

Commit ec408845bc0f ("hwmon: (nct7802) Use multi-byte regmap
operations") from Jul 9, 2024 (linux-next), leads to the following
Smatch static checker warning:

    drivers/hwmon/nct7802.c:411 in_alarm_show()
    error: double locked '&data->access_lock' (orig line 406)

drivers/hwmon/nct7802.c
     375 static ssize_t in_alarm_show(struct device *dev, struct device_attribute *attr,
     376                              char *buf)
     377 {
     378         struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
     379         struct nct7802_data *data = dev_get_drvdata(dev);
     380         int volt, min, max, ret;
     381         unsigned int val;
     382
     383         mutex_lock(&data->in_alarm_lock);
     384
     385         /*
     386          * The SMI Voltage status register is the only register giving a status
     387          * for voltages. A bit is set for each input crossing a threshold, in
     388          * both direction, but the "inside" or "outside" limits info is not
     389          * available. Also this register is cleared on read.
     390          * Note: this is not explicitly spelled out in the datasheet, but
     391          * from experiment.
     392          * To deal with this we use a status cache with one validity bit and
     393          * one status bit for each input. Validity is cleared at startup and
     394          * each time the register reports a change, and the status is processed
     395          * by software based on current input value and limits.
     396          */
     397         ret = regmap_read(data->regmap, 0x1e, &val); /* SMI Voltage status */
     398         if (ret < 0)
     399                 goto abort;
     400
     401         /* invalidate cached status for all inputs crossing a threshold */
     402         data->in_status &= ~((val & 0x0f) << 4);
     403
     404         /* if cached status for requested input is invalid, update it */
     405         if (!(data->in_status & (0x10 << sattr->index))) {
     406                 ret = nct7802_read_voltage(data, sattr->nr, 0);

I believe that the mutex_lock(&data->access_lock); in nct7802_read_voltage()
was supposed to be deleted.


Oops, most definitely yes.


This is now fixed.

Again, thanks a lot for the report.

Guenter





[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