Bug 188871 - Function ad7150_write_event_config() does not return error codes on failures
Summary: Function ad7150_write_event_config() does not return error codes on failures
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Staging (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_staging@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 11:05 UTC by bianpan
Modified: 2017-05-12 00:01 UTC (History)
0 users

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments
The patch fixes the bug (952 bytes, patch)
2017-05-12 00:00 UTC, bianpan
Details | Diff

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.

Note You need to log in before you can comment on or make changes to this bug.