From: Dan Carpenter Date: Tue, 2 Apr 2024 09:56:42 +0000 (+0300) Subject: drm/panthor: Fix off by one in panthor_fw_get_cs_iface() X-Git-Tag: io_uring-6.10-20240523~68^2~25^2~4 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=2b5890786014b926f845402ae80ebc71c4bd6d5c;p=linux-2.6-block.git drm/panthor: Fix off by one in panthor_fw_get_cs_iface() The ->iface.streams[csg_slot][] array has MAX_CS_PER_CSG elements so this > comparison needs to be >= to prevent an out of bounds access. Fixes: 2718d91816ee ("drm/panthor: Add the FW logical block") Signed-off-by: Dan Carpenter Reviewed-by: Boris Brezillon Signed-off-by: Boris Brezillon Link: https://patchwork.freedesktop.org/patch/msgid/62835c16-c85c-483d-a8fe-63be78d49d15@moroto.mountain --- diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor/panthor_fw.c index 33c87a59834e..181395e2859a 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.c +++ b/drivers/gpu/drm/panthor/panthor_fw.c @@ -308,7 +308,7 @@ panthor_fw_get_csg_iface(struct panthor_device *ptdev, u32 csg_slot) struct panthor_fw_cs_iface * panthor_fw_get_cs_iface(struct panthor_device *ptdev, u32 csg_slot, u32 cs_slot) { - if (drm_WARN_ON(&ptdev->base, csg_slot >= MAX_CSGS || cs_slot > MAX_CS_PER_CSG)) + if (drm_WARN_ON(&ptdev->base, csg_slot >= MAX_CSGS || cs_slot >= MAX_CS_PER_CSG)) return NULL; return &ptdev->fw->iface.streams[csg_slot][cs_slot];