Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp662225ioo; Thu, 26 May 2022 11:36:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgkubXJpZNr3+cNCqOGBc+u+RLMXiZ5XAn4dqhcuaSM82vIsLXGiLf39YsKEhYFywnKEyB X-Received: by 2002:a17:90b:17c6:b0:1e0:28bf:d429 with SMTP id me6-20020a17090b17c600b001e028bfd429mr4023918pjb.239.1653590189914; Thu, 26 May 2022 11:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653590189; cv=none; d=google.com; s=arc-20160816; b=GxiReeEv6jl9ZrxTEHgkg/VGZ3zwZQRRJbqizduSFkaKwTE4cmJAzqdR9Ha7XubuZG nGjPJPIioug+rvp7jz6s8UWk2mW5+IieOMv69+FkhA2ftD+B3w8vjO76VGKc56bnVQQt 7v+BBn5vGF3yswAGjxUSchqrbwGRONhWYh06owzIS6sbvrmkz02d51DMf5zjzblet6o4 nQaO+7/JS7/H/MnLvw37g0yleUGKU7k9GygjJAZDJ/2qIfJ25I5oZSgIfcNHseqb1IpP DzVc2BzN28CKddDdS12odzZ7WG0h8ur8ic07RVlgxObpezdJE9xdheYm0iPvhcVBkBXY wyPg== 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:cc:to:from:dkim-signature; bh=xf0m+cxj00ml2J9yglsVjh3XZlLBOWXtU5mmNEGwQ3U=; b=LEnPPp7wXE5aDtnV3jPZVIDEK2DgComZrBum6dUv/1TkAdwM79FsgBT64X2wlZTLUS WkUFA0ql6KUyz28KUA6Uez6Lz/5cOg5qrC1mh5Ux1ECUH+lKc577pql3Txo+YQyvoHke +dzrnK8sVU3wQKA20inHiY2aSVIFvcSbVhbjfdGbTolYiTZhLScqTdu9LZHFehqPmG1L iV/gmkUqYPFkwTBwXvZddSY7aqqi+pvgnETrCawTqEVBt9FZHks9VPHvZumOAfZ65vUa VfajYuS4C3+ioXkb90xskc7eMTOaxiwwpteGojTMIj24IIjWUO/LFQYAzq3Xye4zxDsP OBBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i642uYY+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020aa7980b000000b0050dfedd9c62si2631430pfl.292.2022.05.26.11.36.16; Thu, 26 May 2022 11:36:29 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i642uYY+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241708AbiEZIiF (ORCPT + 99 others); Thu, 26 May 2022 04:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233597AbiEZIiA (ORCPT ); Thu, 26 May 2022 04:38:00 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A72C8D697; Thu, 26 May 2022 01:37:59 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id l20-20020a17090a409400b001dd2a9d555bso1196756pjg.0; Thu, 26 May 2022 01:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xf0m+cxj00ml2J9yglsVjh3XZlLBOWXtU5mmNEGwQ3U=; b=i642uYY+wNCW0IASrgCRqqUrpcyvz5d7Y5qfZhMhirG9Tm3cfZwhsci4yxhdFfngQS iiLYP2kYMX2o8DP7FpRPczN05j8zdJOm6GzMxIRc++95E4XlXesmhSLzVE45TbbXvRtO 2IA3/6rGlxgRyhXT2zHzL073VKF2HjW5jrH8MCB/IfSaNRTHB8ZrWS7/xyhwEzW4cZ5q qhCDS4D+LmZfEruPup0LJjJ1ijKFKsxsCE0dd0zTHO5q9etGVnslIQHQap4RdKqJbwhE pbi8NMbo3e4Q22lYdpf1ytGoC23bbj8zimwxRuVIT3cCSptA1tEQRnm4cwqzh6uB6cxz WzAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xf0m+cxj00ml2J9yglsVjh3XZlLBOWXtU5mmNEGwQ3U=; b=Cv9xWbAY60BNqCiGF+VyJf/Gerr+yRHpPhLVpEZmHua4ubmUjA5myFtjKdA1iAnXiW IzOuMPhus89IKCqyC05xjDCdrhuAm6jom8PHi1P9imQ8Gse41JFzF9L56wPj1/5it3AC P/o3mz06W8MMQ/51ClfQF7Omza64Yp6kfye4lTCm7bW9AZPWD8WqLz2RBnvLDMfK7W45 47/AJUf1bllvFpCloZh68PNYuPVIePny0vSrBVGONLLIToI7stjEDMLA6T8aCmeMbTgO hnsX0fgA3JB6sms3DUPVApIPyXTc6KVx1JIWVJLCj2lx7YWet5d6GCgcVMlYdG3rgqr3 grzA== X-Gm-Message-State: AOAM531xUFtdBHb2G8WiXcxnpc/5T+iR48eoeUTgLw4gOlZ5KdJZApuu 0Ft2ZejcK/4P2b+qplJQjxw= X-Received: by 2002:a17:90a:31cf:b0:1c9:f9b8:68c7 with SMTP id j15-20020a17090a31cf00b001c9f9b868c7mr1510376pjf.34.1653554278500; Thu, 26 May 2022 01:37:58 -0700 (PDT) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id k71-20020a63844a000000b003db7de758besm964332pgd.5.2022.05.26.01.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 01:37:58 -0700 (PDT) From: Miaoqian Lin To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linmq006@gmail.com Subject: [PATCH] net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register Date: Thu, 26 May 2022 12:37:48 +0400 Message-Id: <20220526083748.39816-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. This function missing of_node_put() in an error path. Add missing of_node_put() to avoid refcount leak. Signed-off-by: Miaoqian Lin --- drivers/net/dsa/mv88e6xxx/chip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 5d2c57a7c708..0726df6aeb1f 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3960,8 +3960,10 @@ static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, */ child = of_get_child_by_name(np, "mdio"); err = mv88e6xxx_mdio_register(chip, child, false); - if (err) + if (err) { + of_node_put(child); return err; + } /* Walk the device tree, and see if there are any other nodes * which say they are compatible with the external mdio -- 2.25.1