From patchwork Wed Mar 31 09:38:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Grassein X-Patchwork-Id: 12174945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 698E6C433C1 for ; Wed, 31 Mar 2021 09:38:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C16F619BB for ; Wed, 31 Mar 2021 09:38:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C16F619BB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74CF76EA2D; Wed, 31 Mar 2021 09:38:37 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 36AA889BCD for ; Wed, 31 Mar 2021 09:38:33 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id j7so18999618wrd.1 for ; Wed, 31 Mar 2021 02:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h0xPKy60RGRlrev5fEcU3M4WrFhStqfph3HoV43RDcQ=; b=gYpv3RLiQWU/W3F7huLe1EQl8/VbHH0JJNmMpS09zAejEUFBuKzdhuXlAHxYVBdvO2 dqIvkUqlJyYp3505guwSUNBVMEVN7o/RZgGXL7lByqfpLsklNNcXBowLExDYvrKAJUJe H4e6IcI+0rVyzV2sdyh0NydRWUPAZF7Zs92UURZpNK0uKA33I7xAK7c5oeZUqRd7MV88 VfDTi8yHYAEU5mu3sC1eRofEsovmXetvgIQ12yhw6dvOncP3Sp1zkWV7z3JZYvPgvTFV MfqZ83g+iNYe6qT7wVyxB5buYRJdoo3Qn7PnIa+6ruwMe15ZYmGHDY2EEkNbisWeBct+ LTWw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=h0xPKy60RGRlrev5fEcU3M4WrFhStqfph3HoV43RDcQ=; b=BKxjq3yptIIF0WopAQdwu4/PxF92lutcaSSxTYbt89iQzuJA0dmXHbniB8XqFjw2Gu ZT+Uw54Jg6RkSP0KvCTvlsAR2huNl6ZGOVn4i6sEZ5TVNG7oVzKwarD0IYFC13ELwvg6 PtYDnDy/fdXBYi4INr+UjznFI71oUTSZpdqPsD9TQfW0ubL4qTd/RJ91yYocAunpBcat Cn32acp2bqsbpRjsgnWIX3aYJoDtBqx9L+klHqGahV6EaxHTHZ6HWHuYgvfmIISReSoG QrTNOKzPO8NRNb0A9Y0rzlU6sIiTVrgwXnN7WqUX55H0wk7Wd0z4Un0zMRU/X26zo0DW cXrQ== X-Gm-Message-State: AOAM531dhpX01+Ej8OJPHEfsFK3KnI2ONNdtVikWqENULJsKWIsigLl5 WfIJIciSUvP++MPxNZoOcNw= X-Google-Smtp-Source: ABdhPJwqq3Y4TGttxKb5oxuoasweoUD/Uw+BGwiTmpy+ohchjAWFEoS8GoIx3n2MA4N7s3ytTuu/Cg== X-Received: by 2002:adf:bb4c:: with SMTP id x12mr2567753wrg.271.1617183511903; Wed, 31 Mar 2021 02:38:31 -0700 (PDT) Received: from localhost.localdomain (2a01cb0008bd27007d57ea0d08d946c1.ipv6.abo.wanadoo.fr. [2a01:cb00:8bd:2700:7d57:ea0d:8d9:46c1]) by smtp.gmail.com with ESMTPSA id n8sm3037594wrm.70.2021.03.31.02.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 02:38:31 -0700 (PDT) From: Adrien Grassein To: Subject: [PATCH v1 1/1] drm/bridge: lt8912b: Fix issues found during static analysis Date: Wed, 31 Mar 2021 11:38:22 +0200 Message-Id: <20210331093822.251839-2-adrien.grassein@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210331093822.251839-1-adrien.grassein@gmail.com> References: <20210331093822.251839-1-adrien.grassein@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, dan.carpenter@oracle.com, Adrien Grassein Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Some issues where found during static analysis of this driver. Reported-by: Dan Carpenter Suggested-by: Dan Carpenter Signed-off-by: Adrien Grassein --- drivers/gpu/drm/bridge/lontium-lt8912b.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c index 61491615bad0..9a5a19655362 100644 --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c @@ -635,13 +635,15 @@ static int lt8912_parse_dt(struct lt8912 *lt) lt->gp_reset = gp_reset; endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); - if (IS_ERR(endpoint)) { - ret = PTR_ERR(endpoint); - goto end; - } + if (!endpoint) + return -ENODEV; lt->data_lanes = of_property_count_u32_elems(endpoint, "data-lanes"); of_node_put(endpoint); + if (lt->data_lanes < 0) { + dev_err(lt->dev, "%s: Bad data-lanes property\n", __func__); + return lt->data_lanes; + } lt->host_node = of_graph_get_remote_node(dev->of_node, 0, -1); if (!lt->host_node) { @@ -658,16 +660,18 @@ static int lt8912_parse_dt(struct lt8912 *lt) } lt->hdmi_port = of_drm_find_bridge(port_node); - if (IS_ERR(lt->hdmi_port)) { + if (!lt->hdmi_port) { dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__); - ret = PTR_ERR(lt->hdmi_port); - of_node_put(lt->host_node); - goto end; + ret = -ENODEV; + of_node_put(port_node); + goto err_free_host_node; } if (!of_device_is_compatible(port_node, "hdmi-connector")) { dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__); + of_node_put(port_node); ret = -EINVAL; + goto err_free_host_node; } of_node_put(port_node);