Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp403894pxa; Wed, 19 Aug 2020 04:53:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQKqVT6l9flfSVoxuzkJ7Tn7IHDL/ZK8jL4nlvHTId0t2FwjwmM3bkXce0iMndiiGNOjPH X-Received: by 2002:aa7:d654:: with SMTP id v20mr24574249edr.314.1597838035466; Wed, 19 Aug 2020 04:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597838035; cv=none; d=google.com; s=arc-20160816; b=d6dLlpqQ2t5PlDjm+dRNXpgQi2k4dP3845ZHQP9HIgpVUcrFonzMsZ1O11iRmNOCmx 0MQZ1RbPL0aYPJRuCODvm3sS7W/JxSrPhqmE6sJGJDJZ9jwiFBuBviX2Ff1w7FrR2f7z 8t57GPxxe9cI83dbpOfHeoG10IdA87smyHa0HyK8ky6L4eAV98V5ZhrCZsX6ncpIulkC hQB6+83UHOD4JvMO0wI3Zy713VVeelhO+xZ99Lg/cWWgw/OHHuHEH6g7Sd6w0SeQeRDO z7YMG42TMNbj6Yh4ZWkHr3nEhAob1QHT6+pfL9ypxDwq10AFRIRUva3zgHXAPkpsXqcr tMAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=XAVH6XQY0p2A2mlaoUV2EWDz2EkqjEP3+H3G4vKUDkI=; b=HNkyvHP4zhjca2qB08JjLSB90JYWUm1BeqCJempAo8sy6lNr148gjGw3Aiu9BL4wO5 Y6GRrhRwdwvJBP1+bqWj6D89ztkjuAcz92lNurJN+vs+RRsp0sQI36fmpfwgyIf7yhUG 3iJFUjryyyHhb49pXv+/X1dy4aBmBbYbcmWpPSSE9fBxyxTorWYcD/VLfjT3sRSmXYql lfedCnN7gsyAOUW/T8M/vRnl+qY23BKBECCaVIZ2zXenG3KqhGPdzN6RTbszBtdATtbC HrJps2KrBE3FDXkBqfy3XUSXGp0H8BmZ7EfUo9RkGlBJ8LibkYdaN89aYbbMXd4mRdqV H4Ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si14774419edw.580.2020.08.19.04.53.22; Wed, 19 Aug 2020 04:53:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728424AbgHSLv0 (ORCPT + 99 others); Wed, 19 Aug 2020 07:51:26 -0400 Received: from mail.zju.edu.cn ([61.164.42.155]:41548 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728382AbgHSLuo (ORCPT ); Wed, 19 Aug 2020 07:50:44 -0400 Received: from localhost.localdomain (unknown [210.32.144.184]) by mail-app2 (Coremail) with SMTP id by_KCgBHF7z3ET1fwy8CAg--.51675S4; Wed, 19 Aug 2020 19:50:19 +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 , Greg Kroah-Hartman , Eugen Hristev , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: wilc1000: Fix memleak in wilc_sdio_probe Date: Wed, 19 Aug 2020 19:50:14 +0800 Message-Id: <20200819115014.28955-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: by_KCgBHF7z3ET1fwy8C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2KfnxnUUI43ZEXa7VUbeT5PUUUUU== X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgcLBlZdtPihowAjsu Sender: linux-wireless-owner@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 --- 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"); -- 2.17.1