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: 9962999 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 AEEDC601D5 for ; Thu, 21 Sep 2017 00:14:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FF362920B for ; Thu, 21 Sep 2017 00:14:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92CBA29272; Thu, 21 Sep 2017 00:14:16 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C28AC2920B for ; Thu, 21 Sep 2017 00:14:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 062296E7F7; Thu, 21 Sep 2017 00:14:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x236.google.com (mail-pg0-x236.google.com [IPv6:2607:f8b0:400e:c05::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id E4F4C6E7F7 for ; Thu, 21 Sep 2017 00:14:10 +0000 (UTC) Received: by mail-pg0-x236.google.com with SMTP id j70so2577861pgc.10 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=gBLM8L8Cur+m/Wo4WxZYrlFJxNr9D6qmz5IZzI1Yjtq/sbq+2pIuYYuBHiWIKZfYnx EnX+rTdgG5Bj3wHZnbwTArhpKm8J/uN5xC+9y49YJSGT1OE/Cekn192UyViZk836ex3H Yj5kCGkFoEbS/aPPcMljC9vEfuWpx4b7Efm679ZjGweGdSWBEtaNcQ86vJoVgagh08+A xXPvblnF9A7aoJeXvR4Nyxq0VckU/O3mLpWsJ2k8Ey4wiqtq1dfHlHfT9/EuZqTJQIKa XeZYSzP7JQ8zSsLSgwjwtlsi+nWIwBnK+KTsr9AxDMWPSteKAc534J/L6aVD6YfzDVOS Czdg== X-Gm-Message-State: AHPjjUixKrlYogTMjevM9qcpLJr5GnflHjAN/++a0TzF0Er2WuLSAvmg aLwDuGXRjedjHpzV5kd9uJCuxoPynmo= 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 Cc: linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 Reviewed-by: Mark Yao --- 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;