From: Frank Li <Frank.Li@nxp.com>
To: frank.li@nxp.com
Cc: alexandre.belloni@bootlin.com, conor.culhane@silvaco.com,
imx@lists.linux.dev, joe@perches.com,
linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
miquel.raynal@bootlin.com, zbigniew.lukwinski@linux.intel.com
Subject: [PATCH 1/1] i3c: master: svc: return error when read length bigger than 255
Date: Wed, 10 Jan 2024 17:25:03 -0500 [thread overview]
Message-ID: <20240110222503.2381599-1-Frank.Li@nxp.com> (raw)
RDTERM in MCTRL is 8 bits. Add a length check to prevent silent data errors
when the read length exceeds 255 bytes during each i3c_priv_xfer operation.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/i3c/master/svc-i3c-master.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index bd10bb698da0f..181b56953fb28 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -1375,6 +1375,11 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
cmd->len = xfers[i].len;
cmd->actual_len = xfers[i].rnw ? xfers[i].len : 0;
cmd->continued = (i + 1) < nxfers;
+
+ if (cmd->rnw && cmd->len > 255) {
+ dev_err(master->dev, "only support read less than 255 each xfer\n");
+ return -EINVAL;
+ }
}
mutex_lock(&master->lock);
--
2.34.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next reply other threads:[~2024-01-10 22:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 22:25 Frank Li [this message]
2024-01-11 0:15 ` [PATCH 1/1] i3c: master: svc: return error when read length bigger than 255 Alexandre Belloni
2024-01-11 17:29 ` Frank Li
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=20240110222503.2381599-1-Frank.Li@nxp.com \
--to=frank.li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=conor.culhane@silvaco.com \
--cc=imx@lists.linux.dev \
--cc=joe@perches.com \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=zbigniew.lukwinski@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).