提交 0b25abbc 编写于 作者: H Hangyu Hua 提交者: Zheng Zengkai

drm: bridge: sii8620: fix possible off-by-one

stable inclusion
from stable-v5.10.137
commit 7f29d75693dcef2baeb3ea20c71fb6ebec5cc7ad
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I60PLB

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7f29d75693dcef2baeb3ea20c71fb6ebec5cc7ad

--------------------------------

[ Upstream commit 21779cc2 ]

The next call to sii8620_burst_get_tx_buf will result in off-by-one
When ctx->burst.tx_count + size == ARRAY_SIZE(ctx->burst.tx_buf). The same
thing happens in sii8620_burst_get_rx_buf.

This patch also change tx_count and tx_buf to rx_count and rx_buf in
sii8620_burst_get_rx_buf. It is unreasonable to check tx_buf's size and
use rx_buf.

Fixes: e19e9c69 ("drm/bridge/sii8620: add support for burst eMSC transmissions")
Signed-off-by: NHangyu Hua <hbh25y@gmail.com>
Reviewed-by: NAndrzej Hajda <andrzej.hajda@intel.com>
Signed-off-by: NRobert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220518065856.18936-1-hbh25y@gmail.comSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 314c8683
...@@ -605,7 +605,7 @@ static void *sii8620_burst_get_tx_buf(struct sii8620 *ctx, int len) ...@@ -605,7 +605,7 @@ static void *sii8620_burst_get_tx_buf(struct sii8620 *ctx, int len)
u8 *buf = &ctx->burst.tx_buf[ctx->burst.tx_count]; u8 *buf = &ctx->burst.tx_buf[ctx->burst.tx_count];
int size = len + 2; int size = len + 2;
if (ctx->burst.tx_count + size > ARRAY_SIZE(ctx->burst.tx_buf)) { if (ctx->burst.tx_count + size >= ARRAY_SIZE(ctx->burst.tx_buf)) {
dev_err(ctx->dev, "TX-BLK buffer exhausted\n"); dev_err(ctx->dev, "TX-BLK buffer exhausted\n");
ctx->error = -EINVAL; ctx->error = -EINVAL;
return NULL; return NULL;
...@@ -622,7 +622,7 @@ static u8 *sii8620_burst_get_rx_buf(struct sii8620 *ctx, int len) ...@@ -622,7 +622,7 @@ static u8 *sii8620_burst_get_rx_buf(struct sii8620 *ctx, int len)
u8 *buf = &ctx->burst.rx_buf[ctx->burst.rx_count]; u8 *buf = &ctx->burst.rx_buf[ctx->burst.rx_count];
int size = len + 1; int size = len + 1;
if (ctx->burst.tx_count + size > ARRAY_SIZE(ctx->burst.tx_buf)) { if (ctx->burst.rx_count + size >= ARRAY_SIZE(ctx->burst.rx_buf)) {
dev_err(ctx->dev, "RX-BLK buffer exhausted\n"); dev_err(ctx->dev, "RX-BLK buffer exhausted\n");
ctx->error = -EINVAL; ctx->error = -EINVAL;
return NULL; return NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册