diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2018-04-03 15:11:50 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2018-04-11 17:33:46 -0400 |
commit | 1eace8344c02c625ee99cc3ffa50187ded2c87b5 (patch) | |
tree | b8aabc3206f9064036a78593069ddf824f095aa2 | |
parent | 090cecc669d4336a6ce2eeaa3074b628d3fb7678 (diff) |
i2c: add param sanity check to i2c_transfer()
The API docs describe i2c_transfer() as taking a pointer to an array
of i2c_msg containing at least 1 entry, but leaves it to the individual
drivers to sanity check the msgs and num parameters. Let's do this in
core code instead.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
[wsa: changed '<= 0' to '< 1']
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r-- | drivers/i2c/i2c-core-base.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 1adeebaa81b0..1ba40bb2b966 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c | |||
@@ -1845,6 +1845,9 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
1845 | unsigned long orig_jiffies; | 1845 | unsigned long orig_jiffies; |
1846 | int ret, try; | 1846 | int ret, try; |
1847 | 1847 | ||
1848 | if (WARN_ON(!msgs || num < 1)) | ||
1849 | return -EINVAL; | ||
1850 | |||
1848 | if (adap->quirks && i2c_check_for_quirks(adap, msgs, num)) | 1851 | if (adap->quirks && i2c_check_for_quirks(adap, msgs, num)) |
1849 | return -EOPNOTSUPP; | 1852 | return -EOPNOTSUPP; |
1850 | 1853 | ||