From patchwork Thu Dec 8 10:55:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 31288 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp127962wrr; Thu, 8 Dec 2022 03:04:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf6CaxDm22wrgTOIg1SYlK3zSCVXnVKWuOt4a0F93QoeiOljTXy1p1NVf/33/aKiEqduBjtB X-Received: by 2002:a17:906:c44a:b0:7c0:d6bb:fd7 with SMTP id ck10-20020a170906c44a00b007c0d6bb0fd7mr17575461ejb.726.1670497484005; Thu, 08 Dec 2022 03:04:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670497483; cv=none; d=google.com; s=arc-20160816; b=HP4VXfV0+lyeakc5uqunX1vzEcltKh4TSCO9unS831g56B4nQR8a+9RLCyX+fVqUxx M59MoW6pIJYojuwMn44+LFbqBiQ2XOrnPhGQUnPDC0MQ1Twm5X+iryXJu+tjd7N9n28e pBIPjOOr+NkyClngI/paYuXOPSzVzrmqrp+mp5DydvIluaG2q+QjIZSriNlWcIUVuEtz NkyN22+5ShznuULma8hIgSIWCWn67yr9OcIIhSO4fkQ4xJMe6FaAK3AQgPE6xMZNousz IMQHlw7VtRdRo50LlYNg1onh45g99e75YWVINIJ+gjgXddmJOxOe4D4HDJ527Ww+u85T 2Q5g== 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=0cfGChK9oJGmB6vVDiSrMa3ogbKL7hgLs0u907jieWw=; b=or3PLm7AzLRy0sqCs780ISmg6I/SURrmgVSuO9yvnapONFrTq5g53bwDFL4Ckd9x8y bm8DVntNj7HKLl0E96M3QTHgi3ScG5abwRqC71sHi11FQ40Y2/Af1mhg1OheINWHdrpC vVoJeUNqg3rUSRZDkwuoJf0TUoAuvj2SG5JPShG9lIxc2zVajTYuwbjKfdv7QUwS0nWq o+FgFiWnFYYuRp2+wwVYhFteH/JzkLkjiAziqqwcER3DzXF1nt/uyk5a3T9hVDroP5f7 PtRcQ8RqBWsWPR9H92dPyTkDeN/0RWq/opDBSjvsG+ew8wD8Kt4cNkp5vS/sc3meZr6w 3s6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gQijJEMd; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di21-20020a170906731500b007c12c63d1f4si1201454ejc.813.2022.12.08.03.04.19; Thu, 08 Dec 2022 03:04:43 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=gQijJEMd; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229637AbiLHLAt (ORCPT + 99 others); Thu, 8 Dec 2022 06:00:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbiLHLAN (ORCPT ); Thu, 8 Dec 2022 06:00:13 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04A192677; Thu, 8 Dec 2022 02:55:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A079EB82396; Thu, 8 Dec 2022 10:55:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B3DBC433C1; Thu, 8 Dec 2022 10:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670496942; bh=OtqWu+aDjadxVuvyRi4BAI56AMslW80IYarQiIJA7e0=; h=From:To:Cc:Subject:Date:From; b=gQijJEMdCmHyZjO0UuTDe3wRIednN+54/3N4FMY+E5t2qjy5gXBf9XSEqfkxz8yG9 ZPx79XhwHov5QwYIcRZMdK02QVCya3GawEc+CqvbFzQhjUKGm7WUwApylzUblj1cjZ OZnY+KTU0xktR5tZ6mnMYnGF+FB0dqgjRHt0vRH63kQItSi9jceqWoivA/61AbNXR+ 2C4y/STnPkrqhwJqC+vDHKJMNL/ViT+AGtm8F6tWTmQkZXJitVVNUSz8DHQ0J86OPt rrxCJgWK5n4wRM3HozEMMR2ND26PeMS/FqPVZAbvVtuf8zgA11pjnnqKWQF+M+sGRF R0T+E2MV3O9bw== From: Roger Quadros To: davem@davemloft.net, maciej.fijalkowski@intel.com, kuba@kernel.org Cc: andrew@lunn.ch, edumazet@google.com, pabeni@redhat.com, vigneshr@ti.com, s-vadapalli@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH net-next] net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open() Date: Thu, 8 Dec 2022 12:55:34 +0200 Message-Id: <20221208105534.63709-1-rogerq@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751643569695085062?= X-GMAIL-MSGID: =?utf-8?q?1751643569695085062?= Ensure pm_runtime_put() is issued in error path. Reported-by: Jakub Kicinski Signed-off-by: Roger Quadros Reviewed-by: Saeed Mahameed --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index b8f7080434cb..58c20e4c0e9f 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -573,20 +573,21 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev) reg = cpsw_sl_reg_read(port->slave.mac_sl, CPSW_SL_SOFT_RESET); if (reg) { dev_err(common->dev, "soft RESET didn't complete\n"); - return -ETIMEDOUT; + ret = -ETIMEDOUT; + goto runtime_put; } /* Notify the stack of the actual queue counts. */ ret = netif_set_real_num_tx_queues(ndev, common->tx_ch_num); if (ret) { dev_err(common->dev, "cannot set real number of tx queues\n"); - return ret; + goto runtime_put; } ret = netif_set_real_num_rx_queues(ndev, AM65_CPSW_MAX_RX_QUEUES); if (ret) { dev_err(common->dev, "cannot set real number of rx queues\n"); - return ret; + goto runtime_put; } for (i = 0; i < common->tx_ch_num; i++) @@ -594,7 +595,7 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev) ret = am65_cpsw_nuss_common_open(common); if (ret) - return ret; + goto runtime_put; common->usage_count++; @@ -622,6 +623,10 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev) error_cleanup: am65_cpsw_nuss_ndo_slave_stop(ndev); return ret; + +runtime_put: + pm_runtime_put(common->dev); + return ret; } static void am65_cpsw_nuss_rx_cleanup(void *data, dma_addr_t desc_dma)