|
| 1 | +From git@z Thu Jan 1 00:00:00 1970 |
| 2 | +Subject: [PATCH v2 1/2] iio: bmi323: fix copy and paste bugs in suspend |
| 3 | + resume |
| 4 | +From: Dan Carpenter < [email protected]> |
| 5 | +Date: Mon, 16 Sep 2024 17:09:10 +0300 |
| 6 | + |
| 7 | +MIME-Version: 1.0 |
| 8 | +Content-Type: text/plain; charset="utf-8" |
| 9 | +Content-Transfer-Encoding: 7bit |
| 10 | + |
| 11 | +This code is using bmi323_reg_savestate[] and ->reg_settings[] instead |
| 12 | +of bmi323_ext_reg_savestate[] and ->ext_reg_settings[]. This was |
| 13 | +discovered by Smatch: |
| 14 | + |
| 15 | + drivers/iio/imu/bmi323/bmi323_core.c:2202 bmi323_core_runtime_suspend() |
| 16 | + error: buffer overflow 'bmi323_reg_savestate' 9 <= 11 |
| 17 | + |
| 18 | +Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend") |
| 19 | +Signed-off-by: Dan Carpenter < [email protected]> |
| 20 | +Link: https://lore.kernel.org/r/ [email protected] |
| 21 | +--- |
| 22 | +v2: no change |
| 23 | + |
| 24 | + drivers/iio/imu/bmi323/bmi323_core.c | 12 ++++++------ |
| 25 | + 1 file changed, 6 insertions(+), 6 deletions(-) |
| 26 | + |
| 27 | +diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c |
| 28 | +index 89eab40bcfdf..f6ff07ba98cd 100644 |
| 29 | +--- a/drivers/iio/imu/bmi323/bmi323_core.c |
| 30 | ++++ b/drivers/iio/imu/bmi323/bmi323_core.c |
| 31 | +@@ -2193,12 +2193,12 @@ static int bmi323_core_runtime_suspend(struct device *dev) |
| 32 | + } |
| 33 | + |
| 34 | + for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) { |
| 35 | +- ret = bmi323_read_ext_reg(data, bmi323_reg_savestate[i], |
| 36 | +- &savestate->reg_settings[i]); |
| 37 | ++ ret = bmi323_read_ext_reg(data, bmi323_ext_reg_savestate[i], |
| 38 | ++ &savestate->ext_reg_settings[i]); |
| 39 | + if (ret) { |
| 40 | + dev_err(data->dev, |
| 41 | + "Error reading bmi323 external reg 0x%x: %d\n", |
| 42 | +- bmi323_reg_savestate[i], ret); |
| 43 | ++ bmi323_ext_reg_savestate[i], ret); |
| 44 | + return ret; |
| 45 | + } |
| 46 | + } |
| 47 | +@@ -2237,12 +2237,12 @@ static int bmi323_core_runtime_resume(struct device *dev) |
| 48 | + } |
| 49 | + |
| 50 | + for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) { |
| 51 | +- ret = bmi323_write_ext_reg(data, bmi323_reg_savestate[i], |
| 52 | +- savestate->reg_settings[i]); |
| 53 | ++ ret = bmi323_write_ext_reg(data, bmi323_ext_reg_savestate[i], |
| 54 | ++ savestate->ext_reg_settings[i]); |
| 55 | + if (ret) { |
| 56 | + dev_err(data->dev, |
| 57 | + "Error writing bmi323 external reg 0x%x: %d\n", |
| 58 | +- bmi323_reg_savestate[i], ret); |
| 59 | ++ bmi323_ext_reg_savestate[i], ret); |
| 60 | + return ret; |
| 61 | + } |
| 62 | + } |
| 63 | +-- |
| 64 | +2.45.2 |
| 65 | + |
0 commit comments