Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9488116pxu; Mon, 28 Dec 2020 18:25:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOotqoFBY++NhQrqWLBmbK0OZ3MpARkxnUBNBBFPogi2PYl6PeOJ80arYD7bqNkE8/di0a X-Received: by 2002:a17:906:adce:: with SMTP id lb14mr43691545ejb.502.1609208700684; Mon, 28 Dec 2020 18:25:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609208700; cv=none; d=google.com; s=arc-20160816; b=BCCdy+CPzM1N3gSClXaj2bHGC7imrr6NCq4ThY0QvvgIDqKjqwWZdvI+PYdNWaXrOo Tp80jA5lQJ8tvfZWOkoq4OJEOy0bQMhs9f8jMZl36ZhD5NqCoBE0szhYzoNMZGVZRBSl YjI0c1p0QwYUIzXny/o4v8ZeH4aPhpqWFr54g/QRjjG7ewJsG+dno1KAI4WgvtIDXZ1Z j1OAL4v47GLFdvjmwBTt5d5nBD2vZvHzYWHCfqQuKlAlsUJTLE/EnqFJpIevClmeBQSF gLOipCRGBUFAhmuW7QH2hsYgjZGJ0f8zWgOm9c+6SFwQH3CGTOxGfF3njGDT5NOzz7nt ogZQ== 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=A5b+IADSslIgc6+0k23r/f4PyqPHS/L7wj/WnW55RpA=; b=W7zJHMDVUKByVajHrlmvXk1ifwOdVUrzBp0FZIKMxk4BDj3L2zh6SIeiuBV3JNLNb8 4uBF5XVqe/PR1qJ3hRPziikjcwsXHDa2Jpqop+sCXQ+8xjRGe0u4GTNt9rKRM5f3cTkh yd0AEPo2TXXSWtyXX8V7NhLFYCW0NlxPPiSk5wuhtoyiV47x7PkIQz4h4I4lFmfbIWff ShA42KGUzuapc4vlpY0UAE6cI9JzAkNtEPT5cbV3stsjK7N2pCisFKJ3dlJoYXisOTFj XPoDH5Wf+Vt+Si3wVlosKx+WX7LEO1DnWGSViiwho0qy27D0Z9Ygvon8kGbjj9aRiLmm PldA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Eg4sWf7j; 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 h22si18747076ejd.179.2020.12.28.18.24.39; Mon, 28 Dec 2020 18:25:00 -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=Eg4sWf7j; 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 S2437510AbgL1OE5 (ORCPT + 99 others); Mon, 28 Dec 2020 09:04:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:38432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437476AbgL1OEt (ORCPT ); Mon, 28 Dec 2020 09:04:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E63120715; Mon, 28 Dec 2020 14:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164273; bh=28XR6IU3/toudgJLvlMgbXSYNFv/xV0vBVnS+6rUYzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eg4sWf7j21GPQbweDSiwng6eqssMf8V7Mdc4XZfdssq4QCGMGkFwYCFNORjfS5zhc MYBwyTegxaywddnUE24hrnFFbCH6gTmG1exJ1+UU0b11yJNTdyjhvmZnvfm1lnFVrU nfo79M3T1VRIBdU9P1jFS9e1ePDc9Oh2c8o1GzCs= 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.10 123/717] media: v4l2-fwnode: Return -EINVAL for invalid bus-type Date: Mon, 28 Dec 2020 13:42:01 +0100 Message-Id: <20201228125026.849035356@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 d7bbe33840cb4..dfc53d11053fc 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 59b1de1971142..c20e2dc6d4320 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -103,6 +103,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, @@ -112,6 +113,7 @@ enum v4l2_mbus_type { V4L2_MBUS_CCP2, V4L2_MBUS_CSI2_DPHY, V4L2_MBUS_CSI2_CPHY, + V4L2_MBUS_INVALID, }; /** -- 2.27.0