From patchwork Tue Apr 19 12:14:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ziyang Xuan (William)" X-Patchwork-Id: 12819204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C0CC1C433EF for ; Tue, 19 Apr 2022 16:58:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 372CD10E32F; Tue, 19 Apr 2022 16:58:46 +0000 (UTC) X-Greylist: delayed 1210 seconds by postgrey-1.36 at gabe; Tue, 19 Apr 2022 12:16:28 UTC Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by gabe.freedesktop.org (Postfix) with ESMTPS id 472AD10E861 for ; Tue, 19 Apr 2022 12:16:28 +0000 (UTC) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KjMbW1YtLzCqwN; Tue, 19 Apr 2022 19:51:51 +0800 (CST) Received: from container.huawei.com (10.175.104.82) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 19 Apr 2022 19:56:15 +0800 From: Ziyang Xuan To: , , , , , , Subject: [PATCH] drm: of: fix a potential double put bug Date: Tue, 19 Apr 2022 20:14:08 +0800 Message-ID: <20220419121408.1291270-1-william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Mailman-Approved-At: Tue, 19 Apr 2022 16:58:45 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Execute the following coccinelle rule: $make coccicheck COCCI=scripts/coccinelle/iterators/device_node_continue.cocci Get an error report as following: ./drivers/gpu/drm/drm_of.c:292:2-13: ERROR: probable double put. Device node iterators put the previous value of the index variable, when find_panel_or_bridge() return non-zero, it will causes a double put. Fixes: 67bae5f28c89 ("drm: of: Properly try all possible cases for bridge/panel detection") Signed-off-by: Ziyang Xuan --- drivers/gpu/drm/drm_of.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index f4df344509a8..8c3c0bca1af1 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -289,11 +289,12 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, continue; ret = find_panel_or_bridge(node, panel, bridge); - of_node_put(node); /* Stop at the first found occurrence. */ - if (!ret) + if (!ret) { + of_node_put(node); return 0; + } } return -EPROBE_DEFER;