From: wangyouwan@126.com
To: jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com,
mika.westerberg@linux.intel.com, jsd@semihalf.com
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
youwan Wang <wangyouwan@126.com>
Subject: [PATCH] i2c: fix crash with msgs is NULL points
Date: Wed, 10 May 2023 16:40:57 +0800 [thread overview]
Message-ID: <20230510084057.17313-1-wangyouwan@126.com> (raw)
From: youwan Wang <wangyouwan@126.com>
There is some probability that msgs is empty
Signed-off-by: youwan Wang <wangyouwan@126.com>
---
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
next reply other threads:[~2023-05-10 8:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 8:40 wangyouwan [this message]
2023-05-10 9:02 ` [PATCH] i2c: fix crash with msgs is NULL points Mika Westerberg
[not found] ` <1943ca04.6ce1.18804f327f0.Coremail.wangyouwan@126.com>
2023-05-10 9:23 ` Mika Westerberg
2023-05-11 7:01 ` Jarkko Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230510084057.17313-1-wangyouwan@126.com \
--to=wangyouwan@126.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=jsd@semihalf.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox