Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Dec 2021 06:59:18 GMT
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 94859be65dc2 - stable/12 - rk_i2c_transfer: fix off-by-one in check for last message
Message-ID:  <202112220659.1BM6xInj036886@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by avg:

URL: https://cgit.FreeBSD.org/src/commit/?id=94859be65dc2e9633eea10fc3f64c01cdfa182c9

commit 94859be65dc2e9633eea10fc3f64c01cdfa182c9
Author:     Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2021-12-15 08:44:43 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2021-12-22 06:57:11 +0000

    rk_i2c_transfer: fix off-by-one in check for last message
    
    This also fixes an access beyond msgs array.
    
    (cherry picked from commit b6a2aba959c8b30d740c653c96c01fb90a3073f7)
---
 sys/arm64/rockchip/rk_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/arm64/rockchip/rk_i2c.c b/sys/arm64/rockchip/rk_i2c.c
index 35f7cd8a66e5..13fd5cebaf2d 100644
--- a/sys/arm64/rockchip/rk_i2c.c
+++ b/sys/arm64/rockchip/rk_i2c.c
@@ -518,7 +518,7 @@ rk_i2c_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
 			}
 		}
 		/* last message ? */
-		last_msg = (i > nmsgs - 1) ||
+		last_msg = (i >= nmsgs - 1) ||
 		    !(msgs[i + 1].flags & IIC_M_NOSTART);
 		rk_i2c_start_xfer(sc, msgs + i, last_msg);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112220659.1BM6xInj036886>