From patchwork Thu Aug 20 05:48:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dinghao Liu X-Patchwork-Id: 11725481 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E0DA1575 for ; Thu, 20 Aug 2020 05:48:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 155EC207DA for ; Thu, 20 Aug 2020 05:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbgHTFsn (ORCPT ); Thu, 20 Aug 2020 01:48:43 -0400 Received: from mail.zju.edu.cn ([61.164.42.155]:37076 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726819AbgHTFsl (ORCPT ); Thu, 20 Aug 2020 01:48:41 -0400 Received: from localhost.localdomain (unknown [10.192.85.18]) by mail-app4 (Coremail) with SMTP id cS_KCgDnXXmkDj5fFEIiAQ--.30373S4; Thu, 20 Aug 2020 13:48:24 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Ajay Singh , Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , Eugen Hristev , Greg Kroah-Hartman , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] wilc1000: Fix memleak in wilc_sdio_probe Date: Thu, 20 Aug 2020 13:48:19 +0800 Message-Id: <20200820054819.23365-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_KCgDnXXmkDj5fFEIiAQ--.30373S4 X-Coremail-Antispam: 1UD129KBjvJXoWruFWUJF4xAw47Ww1rAr4Dtwb_yoW8Jry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ner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When devm_clk_get() returns -EPROBE_DEFER, sdio_priv should be freed just like when wilc_cfg80211_init() fails. Fixes: 8692b047e86cf ("staging: wilc1000: look for rtc_clk clock") Signed-off-by: Dinghao Liu Acked-by: Ajay Singh --- Changelog: v2: - Remove 'staging' prefix in subject. --- drivers/net/wireless/microchip/wilc1000/sdio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index 3ece7b0b0392..351ff909ab1c 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -149,9 +149,10 @@ static int wilc_sdio_probe(struct sdio_func *func, wilc->dev = &func->dev; wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc"); - if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) + if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) { + kfree(sdio_priv); return -EPROBE_DEFER; - else if (!IS_ERR(wilc->rtc_clk)) + } else if (!IS_ERR(wilc->rtc_clk)) clk_prepare_enable(wilc->rtc_clk); dev_info(&func->dev, "Driver Initializing success\n");