From patchwork Thu Sep 21 00:13:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9963001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 83139601D5 for ; Thu, 21 Sep 2017 00:15:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 735BD2920B for ; Thu, 21 Sep 2017 00:15:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67C3A29282; Thu, 21 Sep 2017 00:15:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C25B32920B for ; Thu, 21 Sep 2017 00:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=XucPnuOojJzVfNhZ1TNx0rJRXl8KJsTFgNYPMIj2i5Q=; b=cH+ Hwlb7VtQdm2tc1cqkkHcum0qHCdRNw+zZF6VuYLeu5dUhM3RRrl+IoSGa8coPHTZNFZt7NXAFvsc0 1efhbqdUHaxRNCJ9xoXPRl7lfn5U6dLTF/vl+COaZwfEysV84fXPBI+P6LDUR6wUroI5SAyCvOSrE cZlONURxibZIXmaMd5IFDcul7kA4EWkG4PJDlrQiTKjVPE5kqWpcptqB0XBharxATB1UYCbOwR2fn XyQI6VKV1OE2JYyw3ZDXefR2MGgQBPZGejGL82ajp6NDGEKmWNuKDMSZF2XCLPgV+B7gkCgwUPq2D cz1A789yipiazSlTq5byaWSsHq5w4/g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dup8W-0005wW-Gh; Thu, 21 Sep 2017 00:14:36 +0000 Received: from mail-pg0-x22b.google.com ([2607:f8b0:400e:c05::22b]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dup8R-0005rk-V3 for linux-arm-kernel@lists.infradead.org; Thu, 21 Sep 2017 00:14:33 +0000 Received: by mail-pg0-x22b.google.com with SMTP id 188so2585932pgb.2 for ; Wed, 20 Sep 2017 17:14:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=+25l9t+CFjEsJkD0WAY+D9qAC8iG7QeAgvvx92GUolU=; b=MY1vKID9iHrjHFX9Nnq6tr5g2oaGU5VkFNygmyp4znl/QY7C7JC3v6XMLbQ0BTtQ9O JTcIMLHuodtzcKQiPrgkf5j63K57YeBSCXCXNgyQ+ddBTs02H9tNEytkUuXAGKjX4yE5 G/J8Ya2T2oUDgu2sCZNm5VgQVFnpsO2R1JsgQ= 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=+25l9t+CFjEsJkD0WAY+D9qAC8iG7QeAgvvx92GUolU=; b=mycJ1fc7/xcztnLUpOVc4XqrGUAjffZKFRSDyOSN4XOL7JqzSO3QF+zJhaV1dJvgBN LUGM9GqZnVWM42gY5ppMpQBZysZWpVZ4sUxmnLkk14IgUXQQx98/4DyH1rDuI67SZJCe QczcjeHqUEn6dHBblkMxoj72hiWTiVHorkaJrGql3YsRk2KnD6ZHp/7ANHpnNm0uGbE/ pmzNwnOSWN/0B7Pqec0sPI7nMuV3XvXeOnnpUy7mYS4GVxjEwTgOSirCZEkShqX3UI1Y RAdbaPaI4aTUPXRGQmMnoRzU0ItIaGH/33TggtWWU+eUm1u8/MDBr/L4OFBBm8BEC1eM XyCA== X-Gm-Message-State: AHPjjUjFH/7wpjuBraFVJEiUjwku8uqSSEWnDEur8VzYPIR+ti6OZ2Bo 3OHDmTFY33zMFwSkrUY+dDfEdw== X-Google-Smtp-Source: AOwi7QACg1S6ibsDHQzDCF/48DkO6geOTRL2IaIHtE+DTD50fn6zh7jxFKkzXQ5WfwUGiNUVGAMrAw== X-Received: by 10.159.246.8 with SMTP id b8mr3655745pls.252.1505952850033; Wed, 20 Sep 2017 17:14:10 -0700 (PDT) Received: from trickycodes.corp.google.com ([172.19.15.95]) by smtp.gmail.com with ESMTPSA id h70sm108103pfc.115.2017.09.20.17.14.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 17:14:09 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/rockchip: Fix uninitialized use of ret Date: Wed, 20 Sep 2017 17:13:56 -0700 Message-Id: <20170921001408.1839-1-seanpaul@chromium.org> X-Mailer: git-send-email 2.14.1.821.g8fa685d3b7-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170920_171432_075968_955EE2B4 X-CRM114-Status: GOOD ( 13.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , David Airlie , Sandy Huang , linux-rockchip@lists.infradead.org, Sean Paul , linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If there are no children for lvds, ret is used uninitialized. This patch initializes ret and returns an error if the port has no children. Fixes: 34cc0aa25456 ("drm/rockchip: Add support for Rockchip Soc LVDS") Cc: Mark Yao Cc: Heiko Stuebner Cc: Sandy Huang Cc: dri-devel@lists.freedesktop.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-rockchip@lists.infradead.org Signed-off-by: Sean Paul --- drivers/gpu/drm/rockchip/rockchip_lvds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c index c5fbe533796c..0ce6205d8d80 100644 --- a/drivers/gpu/drm/rockchip/rockchip_lvds.c +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c @@ -346,7 +346,7 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master, struct drm_connector *connector; struct device_node *remote = NULL; struct device_node *port, *endpoint; - int ret; + int ret = 0, child_count = 0; const char *name; u32 endpoint_id; @@ -358,13 +358,18 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master, return -EINVAL; } for_each_child_of_node(port, endpoint) { + child_count++; of_property_read_u32(endpoint, "reg", &endpoint_id); ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id, &lvds->panel, &lvds->bridge); if (!ret) break; } - if (ret) { + if (!child_count) { + DRM_DEV_ERROR(dev, "lvds port does not have any children\n"); + ret = -EINVAL; + goto err_put_port; + } else if (ret) { DRM_DEV_ERROR(dev, "failed to find panel and bridge node\n"); ret = -EPROBE_DEFER; goto err_put_port;