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 AD4E64C10C4; Thu, 17 Sep 2026 17:35:36 +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=1789666538; cv=none; b=a7ShjNqp/X+m1KK+oJmhvptmIW2euOkZxUxg6obF4Ok3talV9BChPYpysrdaom4DtNRQGA1IiKgBQsdPqg+hntyoGCNQIsDTqooaFJSNuBs/dKk7JfLu72Lv7GmR0cHkfWIqAFKEEMfLiZP3NE6u5/iH4EUTFoMWB968CivO1qg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789666538; c=relaxed/simple; bh=zYrNlnF0j7Y+/nduoda3fJQPsU0APGPJazGLOZAf2is=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kGE/FtRWycUHKmCUAd9FzfC7XJKnlGqbzXdjqsO3y0laV9/c3woTjlq0C3Hyf0g2RZNfSlsXQEYsVk6E+I54IfKwDQM/JqIGlIujLruv4xA8Ep1hxGKWnQZ3cURWSQegLliEmFeEtA864GLKbqPv6sWhR2EhjRl7qMyrrUf2YYw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=c/iGoPNH; 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="c/iGoPNH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAAFF1F000FF; Thu, 17 Sep 2026 17:35:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789666536; bh=G/Q7qvdRYdU10jPSQskwKtvGVUnAOlT68I9gCQpSJ/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=c/iGoPNHLR2hoS3CvmYHHP+inmXYt46Rwy4DihhbdUftw+vx+a8igbhSiA9CbIgHe Kmcf8n4qZkDKNZuPiE5mlaDS4cZQfgnIuTU9uXTQHDU2PISmdQ5aPb0IGjGRgd/yMQ wVzWB9JCDVcsm7PD16U1tDreAxiArB0H0QQUROWg= 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.18 1063/1250] media: v4l2-h264: Fix memcmp() size in B1 reference list comparison Date: Thu, 17 Sep 2026 16:14:18 +0100 Message-ID: <20260917151620.936542969@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151551.901433442@linuxfoundation.org> References: <20260917151551.901433442@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.18-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);