From: youwan Wang <[email protected]>
There is some probability that msgs is empty
Signed-off-by: youwan Wang <[email protected]>
---
drivers/i2c/busses/i2c-designware-master.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 55ea91a63382..e11a73fd0a41 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -366,12 +366,17 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
struct i2c_msg *msgs = dev->msgs;
u32 intr_mask;
int tx_limit, rx_limit;
- u32 addr = msgs[dev->msg_write_idx].addr;
+ u32 addr;
u32 buf_len = dev->tx_buf_len;
u8 *buf = dev->tx_buf;
bool need_restart = false;
unsigned int flr;
+ if (WARN_ON(!msgs))
+ return;
+
+ addr = msgs[dev->msg_write_idx].addr;
+
intr_mask = DW_IC_INTR_MASTER_MASK;
for (; dev->msg_write_idx < dev->msgs_num; dev->msg_write_idx++) {
--
2.25.1
On Wed, May 10, 2023 at 04:40:57PM +0800, [email protected] wrote:
> From: youwan Wang <[email protected]>
>
> There is some probability that msgs is empty
What probabability 0/100? ;-) Can you point a real case when this can
happen?