Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3702869pxb; Tue, 19 Apr 2022 08:13:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpI5E5PKvRp7nb0PAYNuTE3Ele2lG8vCS03DNyZcVMX1YGI7ZrbPIA6Aw+G7f41k836Q6r X-Received: by 2002:a17:90b:3ecc:b0:1d2:c238:d92e with SMTP id rm12-20020a17090b3ecc00b001d2c238d92emr6233005pjb.79.1650381229739; Tue, 19 Apr 2022 08:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650381229; cv=none; d=google.com; s=arc-20160816; b=FaH+tZkgGwim4rxdt1zCYTINyeMDmSeNc9cL+XwPbjeNAaGPWcywx6sXyVTb1JROIg 9+fR/DOkiXRjSHnFytKUpZSOI+gz3caxQOd9hcQe+EvXDfcYUawHyEFaqvXNzHiwFtMj j2061TsxG6zlfWOmM22LuzU+dUlMNpmWBRRRc9NQXE3J43udbIldRkAhNtUbxFuwMia6 g1CzBcSePFyYzRybt9ue7CaEY/Y5+LztBaxyv/S3rAzraMjkZgAUDfyPszIdk23I5cSu e0i5hjcMmOLhH/9KHsyqRc0OZO82vK55IP0KswbK7rSK0d/0fdFrazffuiE9AN8AdolF n/kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=umX7zU1mjp4aeUVtRRGxNjvBft3VGRg7CAlS79S+Cbk=; b=KBVDJOPFAIB9GVEr0ubl3lN1Kwt5YR2bRNl3vAl6TemPtM3+rWX4lMTfJYyfBhir5t XEo8W9TC0RXVSXuyKj2uJEzSlaX8cLxS9fonNKWs/NONjkY2c8kETpRcEGx4otwOBDkp Gr+0+ATpLNBFNsNjoHns5/I2I5HC+AkYjL6l7Fes+bbNCQhL+JMKbp3H6xfcrqef38YK ZQhw3+/+FRQfL95PkF3HbgBnBqxZ1LxyoGaIHDNGP4lMvcHq3rTYx/sBARguX90f7psl ZYElJMmii9N/qwXlAV/563NmyKVp4dBJIt6iFYEa3EMRAdcEO2rWKnd7m2mpR9wtdst8 1BZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u7-20020a056a00098700b0050a9b3e1c5fsi1283879pfg.333.2022.04.19.08.13.32; Tue, 19 Apr 2022 08:13:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242771AbiDSL7D (ORCPT + 99 others); Tue, 19 Apr 2022 07:59:03 -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: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.25.1