mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 19:13:47 +02:00
media: rockchip: rkcif: fix off by one bugs
Change these comparisons from > vs >= to avoid accessing one element
beyond the end of the arrays.
While at it, use ARRAY_SIZE instead of the _MAX enum values.
Fixes: 1f2353f5a1 ("media: rockchip: rkcif: add support for rk3568 vicap mipi capture")
Cc: stable@kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Michael Riesch <michael.riesch@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Chen-Yu Tsai <wens@kernel.org>
[fix cosmetic issues]
Signed-off-by: Michael Riesch <michael.riesch@collabora.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
937ffb7a42
commit
e4056b84af
|
|
@ -489,8 +489,8 @@ static inline unsigned int rkcif_mipi_get_reg(struct rkcif_interface *interface,
|
|||
|
||||
block = interface->index - RKCIF_MIPI_BASE;
|
||||
|
||||
if (WARN_ON_ONCE(block > RKCIF_MIPI_MAX - RKCIF_MIPI_BASE) ||
|
||||
WARN_ON_ONCE(index > RKCIF_MIPI_REGISTER_MAX))
|
||||
if (WARN_ON_ONCE(block >= ARRAY_SIZE(rkcif->match_data->mipi->blocks)) ||
|
||||
WARN_ON_ONCE(index >= ARRAY_SIZE(rkcif->match_data->mipi->regs)))
|
||||
return RKCIF_REGISTER_NOTSUPPORTED;
|
||||
|
||||
offset = rkcif->match_data->mipi->blocks[block].offset;
|
||||
|
|
@ -510,9 +510,9 @@ static inline unsigned int rkcif_mipi_id_get_reg(struct rkcif_stream *stream,
|
|||
block = stream->interface->index - RKCIF_MIPI_BASE;
|
||||
id = stream->id;
|
||||
|
||||
if (WARN_ON_ONCE(block > RKCIF_MIPI_MAX - RKCIF_MIPI_BASE) ||
|
||||
WARN_ON_ONCE(id > RKCIF_ID_MAX) ||
|
||||
WARN_ON_ONCE(index > RKCIF_MIPI_ID_REGISTER_MAX))
|
||||
if (WARN_ON_ONCE(block >= ARRAY_SIZE(rkcif->match_data->mipi->blocks)) ||
|
||||
WARN_ON_ONCE(id >= ARRAY_SIZE(rkcif->match_data->mipi->regs_id)) ||
|
||||
WARN_ON_ONCE(index >= ARRAY_SIZE(rkcif->match_data->mipi->regs_id[id])))
|
||||
return RKCIF_REGISTER_NOTSUPPORTED;
|
||||
|
||||
offset = rkcif->match_data->mipi->blocks[block].offset;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user