Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp995170pxa; Wed, 19 Aug 2020 22:53:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLhoA/9iv2d9JnpOiB8o64FoIt5mgSabhjCOlCsrdyFENgXecD0ft8/oNSGockhG1oNp8I X-Received: by 2002:a17:906:7787:: with SMTP id s7mr1788986ejm.533.1597902829045; Wed, 19 Aug 2020 22:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597902829; cv=none; d=google.com; s=arc-20160816; b=VTFmKLcNofeXEO9uFA4tRmvcXk2sJtt9/MzklW9LS0VlNtYH78B/0Bi2uoSWd67K+P oCOfhlshFRGlgLbC/JbTRxD8GJkC75dQAq3ymDwIRO7HDoysTt4vjQdNQXRAm/2IUQA4 mS7Ne9ACEGFNiTjzbJxParPnH1FqkH8rIoVimc5bEKsVMSy5cD9bHNThvuN3ugBgPmrs 27RVAh02MH4s7hmIYzLk7LTpCXYGCe6iEsZ2S/86fXWRvdLQfbxqO4hRybkwEKWMhvMj GtwwNaaS6nlMde3ywiaUE9TMKnSR3J2YO2V7pfVwZh7ZL/53r8AopfvPSEL1esUihef/ /lBg== 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=doPsjDdiWzlyTr5Cww3r7gbMk8B6/BumlucyZI17Jzs=; b=seroBcGnz6CrnbRtCZsgFeFfp3V0VeiimkZ6DaYZcHifobOMv8HAf4sBa/z1Krd4Wh xZ45zE/hFQsnqk/lg/Mb6jTw/BYyq/nw6LunYuZy82KZgviKS1mkGbXUbHkZ63MHoLEZ ypIAbFuCX6kFhpm3v2mBmV4zXF4yffbWKUqXjhaSez54P7toGxxZ+8xPHy5RzkhfxjtP WGvYYc8X/krlj7EPWD73QM6jmsX8k04xfH0Zu2oHYXPkVhrDo04xL/gyc0cnGFsYPPF+ B2oX4wv5DmxluTPA6w01Eo6j4liOfwZ18z96HyNUaXQDfyd1zJLKmNdBe59LyPHsrEgq Elkg== 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 v17si567636ejd.324.2020.08.19.22.53.24; Wed, 19 Aug 2020 22:53:49 -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 S1725885AbgHTFxQ (ORCPT + 99 others); Thu, 20 Aug 2020 01:53:16 -0400 Received: from spam.zju.edu.cn ([61.164.42.155]:37384 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725866AbgHTFxP (ORCPT ); Thu, 20 Aug 2020 01:53:15 -0400 Received: from localhost.localdomain (unknown [10.192.85.18]) by mail-app4 (Coremail) with SMTP id cS_KCgA3f_+5Dz5fhE0iAQ--.4459S4; Thu, 20 Aug 2020 13:53:01 +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 , Adham Abozaeid , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] wilc1000: Fix memleak in wilc_bus_probe Date: Thu, 20 Aug 2020 13:52:56 +0800 Message-Id: <20200820055256.24333-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_KCgA3f_+5Dz5fhE0iAQ--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ZUUUUU= X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgoSBlZdtPnBhAAPsQ 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, spi_priv should be freed just like when wilc_cfg80211_init() fails. Fixes: 854d66df74aed ("staging: wilc1000: look for rtc_clk clock in spi mode") Signed-off-by: Dinghao Liu --- Changelog: v2: - Remove 'staging' prefix in subject. --- drivers/net/wireless/microchip/wilc1000/spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c index 3f19e3f38a39..a18dac0aa6b6 100644 --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c @@ -112,9 +112,10 @@ static int wilc_bus_probe(struct spi_device *spi) wilc->dev_irq_num = spi->irq; wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc_clk"); - if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) + if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) { + kfree(spi_priv); return -EPROBE_DEFER; - else if (!IS_ERR(wilc->rtc_clk)) + } else if (!IS_ERR(wilc->rtc_clk)) clk_prepare_enable(wilc->rtc_clk); return 0; -- 2.17.1