Received: by 10.223.164.202 with SMTP id h10csp660270wrb; Wed, 15 Nov 2017 06:03:06 -0800 (PST) X-Google-Smtp-Source: AGs4zMYXFSbswgyw8P4hUcVuDYIFINmfKKWP1HOcy7xBKbjgS0OUoVlHwxaeFj2+AjY602CNCYeQ X-Received: by 10.101.91.137 with SMTP id i9mr10464184pgr.313.1510754586108; Wed, 15 Nov 2017 06:03:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510754586; cv=none; d=google.com; s=arc-20160816; b=zfXciPOtloY6WPlgWdoRBIJuIdamFNOx6bTeMfXQByPOlsOtHrpoxA+XSd86oB58j6 mYBFTvlOKgWiysSHxRvOOfMcvIX01ot3n7ZrGicmx6etBzMp6y0z/VATrNx2IerAacyw xNzoYApqBYRzUC6ztNax/GBRbelwi7w1vmZ/y3dhGOTQrszumebgDAzFds+eop2c07fl +Sg30L/RitRf2W89JSGZZZaOKIUmh8oemS8XTf0cDuJMx/XsquUtTU6UoL6bxq6tcj/2 LwLEE6adDgM0CPEXcG9ad66mbizSSV6f2J8cFKeBbtiKXvuH2A8RqF2xAqJR2eKFkCV6 yKLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=FmMpn883QqHI9BCciaXqM9Ptqed18ZyDTUn9kyJPChk=; b=smaS6DJ7kCL632YmTWvtruf/AGnVMsphB4zm73eF7g6rseQAx8hb9n18aBCrSmha3h JuV++6cRkZLNTFJuFWFCaPX42VqveQDUldYsijUrFjEzSyZuG6OpuJm1bYuCzOKS+9d9 w/e00VujkS8PUHlciFV1QjpxqdIpoJx2yv4A6Tq5huZeuZrSq5/+E0X1jRfBYqcCdShl JC4cGiEOXPvBU33rM1cV907WlONtfwevYT26tYcXth0rz1cybUU2fEEgPluwZ8VPsqH0 CuCoszWSwEBH/kN4bLNcQFIkOAuc3xKW+vqU6D0vGsdcaLHilZmxWBxWksuVAnE6JoFJ zwNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=T46R+Yq9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b89si11737777pfc.304.2017.11.15.06.02.52; Wed, 15 Nov 2017 06:03:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=T46R+Yq9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757700AbdKOLzf (ORCPT + 90 others); Wed, 15 Nov 2017 06:55:35 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:47025 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757171AbdKOLz2 (ORCPT ); Wed, 15 Nov 2017 06:55:28 -0500 Received: by mail-pg0-f65.google.com with SMTP id t10so16821519pgo.3 for ; Wed, 15 Nov 2017 03:55:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=FmMpn883QqHI9BCciaXqM9Ptqed18ZyDTUn9kyJPChk=; b=T46R+Yq9SOjDi7R++3E5r+kYRx3wyeUPYbZ1M3a+0NENpvO/0ZtQzPJGLx1qjEAWcZ mkVYSX2sstqc75tN7kYX1LPcFXUJmBKsm6//UNwF23dVWHsv365yPKZbM6hRHEr8OLob /XWbiS5/J3JvpQt5nfLwVvyqfvYN8ZzeCJq9Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FmMpn883QqHI9BCciaXqM9Ptqed18ZyDTUn9kyJPChk=; b=COaQVTsLJ41leFxafFurfy6PN+0p7A7T0BnsZaGfZYrs36jxJ+rQyjY/8b5Sonu2Mf Ykb5KGErxVhoKMYAZFzappny1cW3GYHkXp+iBwZUUw56Bem88pUIRWBHvPNfdg6Z3u3p h7wZd0ks11H6J6Nb3aGMZjY8vW0xyEt0UCljAVsTBdwvsz3IdLA8oW3Au/U/iwdKOMoB 9YlURqPU3UtB5R9YfAK72SynNprbgSUExDFSSFcYfkM07hR1cL4IfTGXwc4ILEk2lA5l +rIxa7xqCgIE4y/ayNxshIgVajOROKpeG04+q6Ebj9jMyAFBnG103UBnk8iCx9FrlqQt UxkQ== X-Gm-Message-State: AJaThX5EAD+9HP/V/JGSiBkd5GK2wdTlFqvAGAVBISVY73KxiSHZpubQ GEhKKZ7HtZTcUnhKjOwE63op4A== X-Received: by 10.84.232.76 with SMTP id f12mr15325564pln.195.1510746928537; Wed, 15 Nov 2017 03:55:28 -0800 (PST) Received: from tfiga.tok.corp.google.com ([2401:fa00:4:1002:3ba3:2aea:6dcf:30b]) by smtp.gmail.com with ESMTPSA id 68sm28102816pfk.162.2017.11.15.03.55.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 03:55:27 -0800 (PST) From: Tomasz Figa To: linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Sebastian Reichel , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Tomasz Figa Subject: [PATCH] media: v4l2-fwnode: Check subdev count after checking port Date: Wed, 15 Nov 2017 20:55:22 +0900 Message-Id: <20171115115522.30211-1-tfiga@chromium.org> X-Mailer: git-send-email 2.15.0.448.gf294e3d99a-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current implementation of __v4l2_async_notifier_parse_fwnode_endpoints() checks first whether subdev_count >= subdev_max and only then whether the port being parsed matches the given port index. This triggers an error in otherwise valid cases of skipping ports that do not match. Fix this by moving the check below the port index check. Fixes: 9ca465312132 ("media: v4l: fwnode: Support generic parsing of graph endpoints in a device") Signed-off-by: Tomasz Figa --- drivers/media/v4l2-core/v4l2-fwnode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 681b192420d9..fb72c7ac04d4 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -458,11 +458,6 @@ static int __v4l2_async_notifier_parse_fwnode_endpoints( if (!is_available) continue; - if (WARN_ON(notifier->num_subdevs >= notifier->max_subdevs)) { - ret = -EINVAL; - break; - } - if (has_port) { struct fwnode_endpoint ep; @@ -474,6 +469,11 @@ static int __v4l2_async_notifier_parse_fwnode_endpoints( continue; } + if (WARN_ON(notifier->num_subdevs >= notifier->max_subdevs)) { + ret = -EINVAL; + break; + } + ret = v4l2_async_notifier_fwnode_parse_endpoint( dev, notifier, fwnode, asd_struct_size, parse_endpoint); if (ret < 0) -- 2.15.0.448.gf294e3d99a-goog From 1583671619514352925@xxx Fri Nov 10 09:42:29 +0000 2017 X-GM-THRID: 1582421821262980114 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread