Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3393099ybp; Sun, 6 Oct 2019 10:57:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4H7zvKJmJjygxaCq8zB8TDLThqbBwEqDIfZ9+g6Y83fA2PHM8Dq82XbS9kDaeFdLYSOa/ X-Received: by 2002:a17:906:eddb:: with SMTP id sb27mr20605875ejb.304.1570384649080; Sun, 06 Oct 2019 10:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384649; cv=none; d=google.com; s=arc-20160816; b=C+UrXR/v2PXSobaAmPGHuM9w0W6F05SGFOBpOUkROMiLtrvSAHRXLR7+YiWBLu5EpA 0L7uW9SAPuCCje6kPB4jgIonAGu9aBBkwJaqEDd6y14s/xQcL6tLTcFyy0iyXZ1Qz3Xb zoBBQX/SRSwUoPzvuy+ilqtrx0P71BEW9p6xEVn6Kd5kHGeQlB3GjGvWGuR4r33K1Ixn 1qi8KeCsKERQGta47EA8coPODv6eKnE/lbTkTeTwPk1HVjPZbzGTOnqh9HxZsJuNsRij eiQBq7NosK0VAl9NI2glb1T/cCCuTJzvC74eJ2cpmbK/XkccOliMecrqZIRJSIAgXv2H jYRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=72BND8bgrhIU0UW0aeY+g7q/POWap4Vc0S0QmSGbZzI=; b=kkITyG31HiC+08JtKkbTFHwvcOvv0aS9V5Ej6Np+OEDc3i9hfhW1i75aEZDlr8IkX8 851VprjNe122l1NggYq0soch9typyQ1gRGyJY2P4zF0CK+FDaOqh+wELgUn9y1yACtCm FkCQlIuVHVxqCPIKfVjud5GRRIr5QfFzooGILcISN0mic0y1Z/RQyslZAgAu9kkty/rD hnFZh4P4zY6K3ECZ8Z8fX+aJ/11vOANUj9pTmdO2fQwROo6oLs5GGiOLjuDtXGsk2kaG Y1Hfno4tkyL7907qxswl4y9xKcAwhcsGrsqQIbAxe24ej9jjAuWQTcgAPF6AyE5E5rLk CQhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1WgbQx9e; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si7010343eda.152.2019.10.06.10.57.05; Sun, 06 Oct 2019 10:57:29 -0700 (PDT) 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=@kernel.org header.s=default header.b=1WgbQx9e; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727658AbfJFR5C (ORCPT + 99 others); Sun, 6 Oct 2019 13:57:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:60948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729056AbfJFReM (ORCPT ); Sun, 6 Oct 2019 13:34:12 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 52C4A2087E; Sun, 6 Oct 2019 17:34:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383251; bh=qqZxm8KNU3bkkqJKEYWUqs8sTqIDkTaNn9u3huRE85Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1WgbQx9erCnUZX18H/9JicJdVrjGttJ0zkfNuR66Rtdg9N6dBSfBRVcF6s18gKUUh 2kgw411wqYAZ4fl9gh39H6z3nU6/VYsJLDKDf890mHu4zuK/SvTYQIhzBsWkcUwNm4 m78aQAEEgt/lyhH18SXTD/zZdKLcvfeRIvRZiGyE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , Sam Ravnborg , Sasha Levin Subject: [PATCH 5.2 034/137] drm/panel: check failure cases in the probe func Date: Sun, 6 Oct 2019 19:20:18 +0200 Message-Id: <20191006171211.971876273@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171209.403038733@linuxfoundation.org> References: <20191006171209.403038733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Navid Emamdoost [ Upstream commit afd6d4f5a52c16e1483328ac074abb1cde92c29f ] The following function calls may fail and return NULL, so the null check is added. of_graph_get_next_endpoint of_graph_get_remote_port_parent of_graph_get_remote_port Update: Thanks to Sam Ravnborg, for suggession on the use of goto to avoid leaking endpoint. Signed-off-by: Navid Emamdoost Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/20190724195534.9303-1-navid.emamdoost@gmail.com Signed-off-by: Sasha Levin --- .../gpu/drm/panel/panel-raspberrypi-touchscreen.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c index 2c9c9722734f5..9a2cb8aeab3a4 100644 --- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c +++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c @@ -400,7 +400,13 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c, /* Look up the DSI host. It needs to probe before we do. */ endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); + if (!endpoint) + return -ENODEV; + dsi_host_node = of_graph_get_remote_port_parent(endpoint); + if (!dsi_host_node) + goto error; + host = of_find_mipi_dsi_host_by_node(dsi_host_node); of_node_put(dsi_host_node); if (!host) { @@ -409,6 +415,9 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c, } info.node = of_graph_get_remote_port(endpoint); + if (!info.node) + goto error; + of_node_put(endpoint); ts->dsi = mipi_dsi_device_register_full(host, &info); @@ -429,6 +438,10 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c, return ret; return 0; + +error: + of_node_put(endpoint); + return -ENODEV; } static int rpi_touchscreen_remove(struct i2c_client *i2c) -- 2.20.1