Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3395452ybp; Sun, 6 Oct 2019 11:00:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKWC5haaBf7nOaCQZVG9SCbD9UXaQmOl/Y1MrbaKtiGkHB9bMoOqq8tT+j4JJaKmwaH7Ny X-Received: by 2002:a05:6402:13c2:: with SMTP id a2mr25115591edx.21.1570384846465; Sun, 06 Oct 2019 11:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384846; cv=none; d=google.com; s=arc-20160816; b=RZxpatmlUUxF7Fg8bnAJlCEE3daiJPTjPlBn8ndEMO1U0/dL8UyggIas9yaqecxWND xMNXZwT5c4wm0LLHj+V5QCEBHs/F9p6LUJWfV81PlJZU+wj3/uaN28bVddmOzVw0e3J9 0pyM4Nln3cdx/oZHRCrVtz0eth36tMej6o7KA4sO+wrva6XsYuXso5QsJYhegUi27dwH Jci9NKDYDca0c54HIJSWO7xuZlxOGk0vNs8tB7M6YH842jMtUC4/nUiNyELdehkdPCQ4 MKnt6YRrHIlyPAsYZve52xNfcTYjIKr1ZvOZFSfN4j75G4HB4VOBVjKcx5xaI8qbjwc9 +cXQ== 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=Sb9CcTzqjPxamFdXV1u5FSOjY2bs4M1gP+5HsyOHLgou2lsYNuV98Ow165mN5pNMUs Ks4DHwC/Kkn1MOCtsfswPc/50tk3Zpld6LQSrgDj8H+sL/to7pixOBbwBMUCXI7GOZwD xRV6fdMaOy4FswV2MWsemDUJC5hq4ZvXO+XOOlVdhTkVOrpBG2woJnylQr92BpPguYND W3O+JhM+T86xIEuQn7lbDhuiEitxm4xLNp8Jlhw+CC1tSK+FM+Z6JuF5bBeRSY2cn7VS 5mHPUYB/Ueu4cstyVuNJnPOWAAZUM3jNqPum8TWOhKanO3yuUsejGiNJL8wRWzMizezU i2Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="NqmX/2lj"; 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 l48si7446521edc.276.2019.10.06.11.00.22; Sun, 06 Oct 2019 11:00:46 -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="NqmX/2lj"; 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 S1729082AbfJFSAH (ORCPT + 99 others); Sun, 6 Oct 2019 14:00:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:55342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728203AbfJFR3g (ORCPT ); Sun, 6 Oct 2019 13:29:36 -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 5F1372080F; Sun, 6 Oct 2019 17:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570382975; bh=qqZxm8KNU3bkkqJKEYWUqs8sTqIDkTaNn9u3huRE85Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NqmX/2lj0ruEqh/hH10rDgml1pvWSma2L20uPKwwyehyTEfNSp1IcLQNmrMs7Ljp4 idul9JaOqHSu6b4QkHHFb3u+92/yq3tjkwPZ9SXC3QEQBpVA2ie0JG+Q4srzB2atVJ IwRH5JHhnFQMfwER9FlqI21rpI2Lg4t3ktho8spg= 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 4.19 007/106] drm/panel: check failure cases in the probe func Date: Sun, 6 Oct 2019 19:20:13 +0200 Message-Id: <20191006171128.466992420@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@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