]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: venus: hfi: fix the check to handle session buffer requirement
authorVikash Garodia <quic_vgarodia@quicinc.com>
Thu, 10 Aug 2023 02:25:02 +0000 (07:55 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 16:56:34 +0000 (16:56 +0000)
commit b18e36dfd6c935da60a971310374f3dfec3c82e1 upstream.

Buffer requirement, for different buffer type, comes from video firmware.
While copying these requirements, there is an OOB possibility when the
payload from firmware is more than expected size. Fix the check to avoid
the OOB possibility.

Cc: stable@vger.kernel.org
Fixes: 09c2845e8fe4 ("[media] media: venus: hfi: add Host Firmware Interface (HFI)")
Reviewed-by: Nathan Hebert <nhebert@chromium.org>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/platform/qcom/venus/hfi_msgs.c

index 9a2bdb002edcc9d0dbe95a50dbaaee1e2d1004d6..68f208e3071d04f13c52fcd98d535985d4692101 100644 (file)
@@ -367,7 +367,7 @@ session_get_prop_buf_req(struct hfi_msg_session_property_info_pkt *pkt,
                memcpy(&bufreq[idx], buf_req, sizeof(*bufreq));
                idx++;
 
-               if (idx > HFI_BUFFER_TYPE_MAX)
+               if (idx >= HFI_BUFFER_TYPE_MAX)
                        return HFI_ERR_SESSION_INVALID_PARAMETER;
 
                req_bytes -= sizeof(struct hfi_buffer_requirements);