From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AA4C3502A8; Wed, 30 Sep 2026 19:15:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790795701; cv=none; b=hYIDziYQF8jsCWwZJ2g91Lwtl4HMUbkQt8s9rLj9pSulHF00fvZLAQlfibuiNJ0DoAb3VRP4SqHsQt0nODLl7vRAmJ19+5OR8RVhWoRtKHNdKYXVijtNq5iHdopt8dlvNoKFoUvwsh3FcaknxrT8VFKMtLfXaM7RxaMzsbXaI5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790795701; c=relaxed/simple; bh=KA/9AhBi7zserlNPD6qgyxEYPph042rwbUUgFwubNzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cQPXmJslV7zLj3jNBLpaHeryAzuhDOr4uedNER9UQNEg4RbBKcQ5TxUTZLyJ3ITrGkIFaL3ua1O5THUKNUETFdkfU/Os/b8g/yp555dRFpeBi9GbDhyNddgelVCqefRcNG/XrsS3LbTtvrT0fq85oSKxdah1cIbv/oaLiROBdRQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PJkm5IFV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="PJkm5IFV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 715161F000FF; Wed, 30 Sep 2026 19:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790795700; bh=zTlrQqrXft/yV5ORnliW3Bkfka+EDa+zNlJVjmQe+tY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PJkm5IFVFRcmzp3oNtfwGE9USEOE+vTH8tJNpNJSI2O98QQ5oPSMXZmt6kgXwNS0J DlbpBU+GceW6ZqTycm0UeNw+Z3IVBJsrtPrPnhv9gh04XnRLYemyLI07Xg1qYcId/o noX64oFflsrklquCkbIqs96M1Z2z/chM2QBZlA+4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nicolas Dufresne , Haotian Zhang , Nicolas Dufresne , Hans Verkuil Subject: [PATCH 6.6 0651/1193] media: v4l2-h264: Fix memcmp() size in B1 reference list comparison Date: Wed, 30 Sep 2026 17:22:15 +0200 Message-ID: <20260930152448.709650411@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haotian Zhang commit 10e59fbdef13597836bd6459095caa02c80af3d7 upstream. In v4l2_h264_build_b_ref_lists(), the B0/B1 list equality check passes the entry count builder->num_valid to memcmp() instead of a byte size. Since struct v4l2_h264_reference is two bytes (fields and index), only half of each list is compared, so distinct lists can be wrongly treated as equal and trigger an incorrect swap(b1_reflist[0], b1_reflist[1]). Change the memcmp() size argument to sizeof(b1_reflist[0]) * builder->num_valid so that the full byte length of both reference lists is compared. Fixes: 624922a2739b ("media: v4l2-core: Add helpers to build the H264 P/B0/B1 reflists") Suggested-by: Nicolas Dufresne Cc: stable@vger.kernel.org Signed-off-by: Haotian Zhang Reviewed-by: Nicolas Dufresne Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-h264.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/media/v4l2-core/v4l2-h264.c +++ b/drivers/media/v4l2-core/v4l2-h264.c @@ -440,7 +440,8 @@ v4l2_h264_build_b_ref_lists(const struct } if (builder->num_valid > 1 && - !memcmp(b1_reflist, b0_reflist, builder->num_valid)) + !memcmp(b1_reflist, b0_reflist, + sizeof(b1_reflist[0]) * builder->num_valid)) swap(b1_reflist[0], b1_reflist[1]); print_ref_list_b(builder, b0_reflist, 0);