From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1364A3FE2D; Mon, 1 Apr 2024 15:49:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711986573; cv=none; b=N7iBgZlMxxfWk6MwNp3skP0JjhY5pfMq0DN5zADLQjwht7ksvTIlUc7CxRj4uMhCfEpJYMDOZwmGOjiJipRjyXttf8l8M1lM0hOONWz59UHaH+mNe3Xpd3zsjGsHrjysXuCIh7B9dTNJDoFPwuLXpOneCOzQy8AOSKZKv94Edfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711986573; c=relaxed/simple; bh=9VyeTwkVR/407CxG/R1phZduSeBbXB82b5scAmIfe0Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=azLz1NS4fAFYPIJqU4r6iZ7JP/lkIgQm2hVg4uNLXzDPxOanNOv8g9sr/JoPH8vO8ESqeZIc0DU8Qp2JYAe0zlbKg0sRh2FCUOwQhkJxpX23C8wEilW2KXZttW6rRr3PKzYie40QGDNMpGYFpcg8scj5ig25qvA+Whw3opzPib4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ixzDfepV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ixzDfepV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A696C43390; Mon, 1 Apr 2024 15:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711986572; bh=9VyeTwkVR/407CxG/R1phZduSeBbXB82b5scAmIfe0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ixzDfepVMEG5mQpyTq8zYu1pk7jHhygPJhuXTcyWLibdGQBqHzduvazim0afd1bB6 w1Z4CapeEobfTpjCE3Z4CaJrDsGgj6JwGuLJ7aRH8AgBgUlG7DNXwYe26l/0crEEBj wvVFN5lzUru+siwv11uzBMnkPg6MKS/zJRXUHZig= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Laurent Pinchart , Sakari Ailus , Hans Verkuil , Sasha Levin Subject: [PATCH 6.8 018/399] media: mc: Fix flags handling when creating pad links Date: Mon, 1 Apr 2024 17:39:44 +0200 Message-ID: <20240401152549.705056963@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152549.131030308@linuxfoundation.org> References: <20240401152549.131030308@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Laurent Pinchart [ Upstream commit 422f7af75d03d50895938d38bc9cb8be759c440f ] The media_create_pad_link() function doesn't correctly clear reject link type flags, nor does it set the DATA_LINK flag. It only works because the MEDIA_LNK_FL_DATA_LINK flag's value is 0. Fix it by returning an error if any link type flag is set. This doesn't introduce any regression, as nobody calls the media_create_pad_link() function with link type flags (easily checked by grepping for the flag in the source code, there are very few hits). Set the MEDIA_LNK_FL_DATA_LINK explicitly, which is a no-op that the compiler will optimize out, but is still useful to make the code more explicit and easier to understand. Cc: stable@vger.kernel.org # 6.1 Signed-off-by: Laurent Pinchart Acked-by: Sakari Ailus Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/mc/mc-entity.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index a6f28366106fb..7839e3f68efa4 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -1092,6 +1092,11 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_link *link; struct media_link *backlink; + if (flags & MEDIA_LNK_FL_LINK_TYPE) + return -EINVAL; + + flags |= MEDIA_LNK_FL_DATA_LINK; + if (WARN_ON(!source || !sink) || WARN_ON(source_pad >= source->num_pads) || WARN_ON(sink_pad >= sink->num_pads)) @@ -1107,7 +1112,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, link->source = &source->pads[source_pad]; link->sink = &sink->pads[sink_pad]; - link->flags = flags & ~MEDIA_LNK_FL_INTERFACE_LINK; + link->flags = flags; /* Initialize graph object embedded at the new link */ media_gobj_create(source->graph_obj.mdev, MEDIA_GRAPH_LINK, -- 2.43.0