Bug 188871

Summary: Function ad7150_write_event_config() does not return error codes on failures
Product: Drivers Reporter: bianpan (bianpan2010)
Component: StagingAssignee: drivers_staging (drivers_staging)
Status: RESOLVED CODE_FIX    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: linux-4.9-rc6 Subsystem:
Regression: No Bisected commit-id:
Attachments: The patch fixes the bug

Description bianpan 2016-11-25 11:05:13 UTC
The function ad7150_write_event_config() defined in file drivers/staging/iio/cdc/ad7150.c directly returns 0 at line 277. As a result, it will return 0 even on failures. However, almost all of other write_event_config() functions (e.g. mma8452_write_event_config() in file drivers/accel/mma8452.c, stk3310_write_event_config() in file drivers/light/stk3310.c) returns negative values on errors. In fact, in function ad7150_write_event_config(), the error codes are assigned to variable ret on failures. Maybe "return 0;" is a typo, and the author intends to "return ret;"? Codes related to this bug are summarised as follows.

ad7150_write_event_config @@ drivers/staging/iio/cdc/ad7150.c
212 static int ad7150_write_event_config(struct iio_dev *indio_dev,
213                      const struct iio_chan_spec *chan,
214                      enum iio_event_type type,
215                      enum iio_event_direction dir, int state)
216 {
217     u8 thresh_type, cfg, adaptive;
218     int ret;
        ...
231     ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG);
232     if (ret < 0)
233         goto error_ret;
        ...
272     /* update control attributes */
273     ret = ad7150_write_event_params(indio_dev, chan->channel, type, dir);
274 error_ret:
275     mutex_unlock(&chip->state_lock);
276 
277     return 0;
278 }

Thanks very much!
Comment 1 bianpan 2017-05-12 00:00:32 UTC
Created attachment 256429 [details]
The patch fixes the bug
Comment 2 bianpan 2017-05-12 00:01:03 UTC
The patch has been merged into the latest version of the Linux kernel. So I will close the bug.