From nobody Mon May 11 01:30:03 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 255C8C433EF for ; Tue, 19 Apr 2022 11:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242804AbiDSL7E (ORCPT ); Tue, 19 Apr 2022 07:59:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236259AbiDSL67 (ORCPT ); Tue, 19 Apr 2022 07:58:59 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37EC21CB01 for ; Tue, 19 Apr 2022 04:56:17 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Execute the following coccinelle rule: $make coccicheck COCCI=3Dscripts/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/p= anel 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_n= ode *np, continue; =20 ret =3D find_panel_or_bridge(node, panel, bridge); - of_node_put(node); =20 /* Stop at the first found occurrence. */ - if (!ret) + if (!ret) { + of_node_put(node); return 0; + } } =20 return -EPROBE_DEFER; --=20 2.25.1