drm: bridge: sii8620: fix possible off-by-one
Subsystems (3)
PATCH 1/1 drm: bridge: sii8620: fix possible off-by-one
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.
--- drivers/gpu/drm/bridge/sil-sii8620.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/sil-sii8620.c +2 -2
@@ -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];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" ); ctx->error = -EINVAL ;return NULL ;
@@ -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];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" ); ctx->error = -EINVAL ;return NULL ;
Signature · 1 line
2.25.1
Quoted 10 lines · Hangyu Hua
The next call to
sii8620_burst_get_tx_bufwill result in off-by-one Whenctx->burst.tx_count+ size ==ARRAY_SIZE(ctx->burst.tx_buf). The same thing happens insii8620_burst_get_rx_buf.This patch also change
tx_countandtx_buftorx_countandrx_bufinsii8620_burst_get_rx_buf. It is unreasonable to check tx_buf's size and userx_buf.Fixes e19e9c692f81 ("drm/bridge/sii8620: add support for burst eMSC transmissions")Signed-off-by Hangyu Hua <[email protected]>
Regards
Andrzej
Quoted 26 lines
--- drivers/gpu/drm/bridge/sil-sii8620.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/bridge/sil-sii8620.c +2
-2@@ -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];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" ); ctx->error = -EINVAL ;return NULL ;@@ -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];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" ); ctx->error = -EINVAL ;return NULL ;
Quoted 35 lines · Andrzej Hajda
Quoted 10 lines · Hangyu Hua
The next call to
sii8620_burst_get_tx_bufwill result in off-by-one Whenctx->burst.tx_count+ size ==ARRAY_SIZE(ctx->burst.tx_buf). The same thing happens insii8620_burst_get_rx_buf.This patch also change
tx_countandtx_buftorx_countandrx_bufinsii8620_burst_get_rx_buf. It is unreasonable to check tx_buf's size and userx_buf.Fixes e19e9c692f81 ("drm/bridge/sii8620: add support for burst eMSC transmissions")Signed-off-by Hangyu Hua <[email protected]>Reviewed-by Andrzej Hajda <[email protected]>Regards
AndrzejQuoted 18 lines
---
drivers/gpu/drm/bridge/sil-sii8620.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/bridge/sil-sii8620.c +1
-1@@ -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]; 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"); ctx->error = -EINVAL; return NULL;@@ -622,7 +622,7 @@ static u8 *sii8620_burst_get_rx_buf(struct sii8620
Quoted 9 lines
drivers/gpu/drm/bridge/sil-sii8620.c static u8 *sii8620_burst_get_rx_buf(struct sii8620 *ctx, int len) · line 628
Quoted 8 lines
drivers/gpu/drm/bridge/sil-sii8620.c +1
-1*ctx, int len) u8 *buf = &ctx->burst.rx_buf[ctx->burst.rx_count]; 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"); ctx->error = -EINVAL; return NULL;
Hi guys,
Another patches for this module that I submitted at the same time as this one have been merged. Is this patch forgotten to merge?
Thanks,
Hangyu
Robert Foss
AppliedQuoted 50 lines · Hangyu Hua
Quoted 38 lines · Andrzej Hajda
Quoted 5 lines · Hangyu Hua
The next call to
sii8620_burst_get_tx_bufwill result in off-by-one Whenctx->burst.tx_count+ size ==ARRAY_SIZE(ctx->burst.tx_buf). The same
thing happens insii8620_burst_get_rx_buf.Quoted 7 lines
This patch also change
tx_countandtx_buftorx_countandrx_bufinsii8620_burst_get_rx_buf. It is unreasonable to check tx_buf's size and userx_buf.Fixes e19e9c692f81 ("drm/bridge/sii8620: add support for burst eMSCtransmissions")
Signed-off-by Hangyu Hua <[email protected]>Reviewed-by Andrzej Hajda <[email protected]>Regards
AndrzejQuoted 19 lines
--- drivers/gpu/drm/bridge/sil-sii8620.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/bridge/sil-sii8620.c +1
-1@@ -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];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" ); ctx->error = -EINVAL ;return NULL ;@@ -622,7 +622,7 @@ static u8 *sii8620_burst_get_rx_buf(struct sii8620Quoted 9 lines
drivers/gpu/drm/bridge/sil-sii8620.c static u8 *sii8620_burst_get_rx_buf(struct sii8620 *ctx, int len) · line 628
Quoted 8 lines
drivers/gpu/drm/bridge/sil-sii8620.c +1
-1*ctx, int len) u8 *buf = &ctx->burst.rx_buf[ctx->burst.rx_count];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" ); ctx->error = -EINVAL ;return NULL ;
Quoted 4 lines
Hi guys,
Another patches for this module that I submitted at the same time as this one have been merged. Is this patch forgotten to merge?
Applied to drm-misc-next.