Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9266185pxu; Mon, 28 Dec 2020 10:52:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgN0z5rrSIJToIOZsp6aoLgXxRdwCrl9PFThfAWGk8NbZrh7P6fL2U0VQj8igaI2cQErOs X-Received: by 2002:a17:906:7fcf:: with SMTP id r15mr44383198ejs.79.1609181523202; Mon, 28 Dec 2020 10:52:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609181523; cv=none; d=google.com; s=arc-20160816; b=UBZuE4HpXXVSscXmcK/fx1QtNvVD4gy1Syks/mJolcPvzhC34mkfd7Ael5V8GBR1iO oekBJXe6Vp2LNQ36+aTRkA5gJxxdtGpNFZXqGe0qP7ArM9fZguxWud2C+3LLbBdXsWiI yCgS7NdhsLmje4h9WEW1CpQzr47/NdoV0cpI5tHKimuqfcdX6ZjOOdfszf0LgcC69Q29 Ut7myMm2OK/bi1C8ZAwxDuO9UKcbnt1Xbs2FFo2bUnIUXUx/4Ze95BLU5D4oBFuC5DcG 8NLjnANM43wH5ALaOgD/g6CLQvUx4xkkJi7nfaCv+X7wO8lutaK4b7DTK6575toKmsTx HUGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+qSP9sLcLM10cSggCBxHqwc9tPV98jT9+LLVilnnTAU=; b=asQYjKEAFNUIUb6bH+OP+B5fbRk1n8VVbUltICX+8MUupKE8T1fLczWUvZQ1WikBrO 82VI5VZZ0+9VXDVeVfttDO/LEZEkjPuraqWrIgkX1DUN0sJmOTYex6O1OuMAv/TJDxw/ X0nrrbo6Asibo/uA9/TkKMU8BzirBAS/zR3DO6n1wczFvro+IQt/I3hQptaTbZauXWN1 WEj1MV+/BY/1UKMdxc6jCH8DwflWqQfkX6FAEUU8w/RQa58ad/uboT2IxuXGaPlKikrY 7rh6sNflm/tOoVS4GJWDZmn8+iLXglcVtsOdQIG9NxSayuZUK9e0AEnqrcWoS3ecIG4C 7mTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BjsXhlnw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e16si18794466ejd.747.2020.12.28.10.51.41; Mon, 28 Dec 2020 10:52:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BjsXhlnw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404687AbgL1Nou (ORCPT + 99 others); Mon, 28 Dec 2020 08:44:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:45162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404587AbgL1No1 (ORCPT ); Mon, 28 Dec 2020 08:44:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F3A7C205CB; Mon, 28 Dec 2020 13:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609163026; bh=718uaZjV8dNsrR/+hDI8u+6rEXV3EMRdfLq49M2Okx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BjsXhlnwiTT4GDmTo59vZzmxie+yN/m+JgWAur7o81CIp8pgVxKdbT4Y7BaTnaGwa FoG9ZFcXnXl8eA38aQFwaeKU9uckqWHupbw6ed7OUqn5qy1dWf1uST5kpslcMPJ0LB Zh3RLU5fzspwtd5D6ZGBqPn8hHhvn2LqSnVingKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lad Prabhakar , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 136/453] media: v4l2-fwnode: Return -EINVAL for invalid bus-type Date: Mon, 28 Dec 2020 13:46:12 +0100 Message-Id: <20201228124943.747974418@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124937.240114599@linuxfoundation.org> References: <20201228124937.240114599@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lad Prabhakar [ Upstream commit 69baf338fc16a4d55c78da8874ce3f06feb38c78 ] Return -EINVAL if invalid bus-type is detected while parsing endpoints. Fixes: 26c1126c9b56 ("media: v4l: fwnode: Use media bus type for bus parser selection") Signed-off-by: Lad Prabhakar Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/v4l2-core/v4l2-fwnode.c | 6 +++++- include/media/v4l2-mediabus.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 3bd1888787eb3..48c3b9f72722a 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -93,7 +93,7 @@ v4l2_fwnode_bus_type_to_mbus(enum v4l2_fwnode_bus_type type) const struct v4l2_fwnode_bus_conv *conv = get_v4l2_fwnode_bus_conv_by_fwnode_bus(type); - return conv ? conv->mbus_type : V4L2_MBUS_UNKNOWN; + return conv ? conv->mbus_type : V4L2_MBUS_INVALID; } static const char * @@ -436,6 +436,10 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode, v4l2_fwnode_mbus_type_to_string(vep->bus_type), vep->bus_type); mbus_type = v4l2_fwnode_bus_type_to_mbus(bus_type); + if (mbus_type == V4L2_MBUS_INVALID) { + pr_debug("unsupported bus type %u\n", bus_type); + return -EINVAL; + } if (vep->bus_type != V4L2_MBUS_UNKNOWN) { if (mbus_type != V4L2_MBUS_UNKNOWN && diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h index 45f88f0248c4e..c072ed1418113 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -78,6 +78,7 @@ * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2) * @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY + * @V4L2_MBUS_INVALID: invalid bus type (keep as last) */ enum v4l2_mbus_type { V4L2_MBUS_UNKNOWN, @@ -87,6 +88,7 @@ enum v4l2_mbus_type { V4L2_MBUS_CCP2, V4L2_MBUS_CSI2_DPHY, V4L2_MBUS_CSI2_CPHY, + V4L2_MBUS_INVALID, }; /** -- 2.27.0