From patchwork Tue Mar 27 20:31:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Folkesson X-Patchwork-Id: 10311599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E99760386 for ; Tue, 27 Mar 2018 20:33:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E85D429C3B for ; Tue, 27 Mar 2018 20:33:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4BEB29DEB; Tue, 27 Mar 2018 20:33:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9775D29C3B for ; Tue, 27 Mar 2018 20:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=PKrWmYBpXINZXd2ITfmnsm5Yl1J9JCS1b5HBDG845nY=; b=D7m rM3O3JkEYpRV35af8drx8Rb6f06GoI3EgHbCDPQsO3rWh7ptX4TDQvtZcGwtknL0rAh0rkO/JSI50 9hr9SE1OBWpYRoAiT1opgtdX9+stSLLizlDALQSlBw4izb8ZNYXgcuHuKaYZetzLYlGoL4COONsgb wRd6JKJNjKcwc1Ww3wzqlsjIvZNmFDXWdUxYkpRwNSH0ytaVmNjx+4XO469adeO9jwu83aCIDRjXd H0/L9pa6WKVtsd0sw8H57NbAMedBy54nFTFSYrmvRd4MsNwpAA+qLW8RIpFW4TnscO0OEaC7Bv/JS go1nQKupcX3hnsRW24GLZxzRURE3ziw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0vGY-0002pH-Mh; Tue, 27 Mar 2018 20:32:22 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0vGI-0002ZU-QV for ath10k@lists.infradead.org; Tue, 27 Mar 2018 20:32:08 +0000 Received: by mail-lf0-x242.google.com with SMTP id o102-v6so272314lfg.8 for ; Tue, 27 Mar 2018 13:31:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=yVsURmxi81Zp/niFdOSM5S/HtaJFLbSGcGCHq4mKpXE=; b=YhIfeOFbZQiOEA2kWxnsWaduWUCkIRrXqoPtpal9xhFaBZSgAPOEQHgnxp7HoQOBpS RcbtR5lJ1DE2jnCcPALqbk8Yrbzld1Fqe1JpOGzNB/GSCnu0HDdJ3gzlsurSgxMQQltD Y3C4QfWz+KiOfEjAbaCXUfYHxfkwiO7ccdyZljvsRERltg2xJK9CJLmAYjVkRABMHV07 6FgxlXWsI2KFY7Gv4eKUCtthqRTmLkxrUgn08FbATMzHW2xIb5Wvhm9oVQA/+RTmeK4t aHBH0SKC5TcP/XnpDZhtlzqiMr4VjzttRAkDdNjsTlphmyPdfRwoT9VVOIkV7BPcmmz9 lFOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yVsURmxi81Zp/niFdOSM5S/HtaJFLbSGcGCHq4mKpXE=; b=co+88i0l9xjlLAgRVskFqqqQR27XPrOjvWWvAGn4w07zPCGIrJnxCTxgXPMGVYrwHd 7O3Bx24qaIeiRT/ccHxF9TMogcyL5X5DUHFl/t7W0LZD2Aqnu5gSQ7VXm6BoLFlF1ngV 2j5PNTeYq1cv/HpdtFK0Zpki9yPjhZtbFVu3G5qGMSkGqJF5bfofjb7i51I93UXXXexx ZwseqqN/pmSxZUTQu5F5+44VoHfFVF7d+KORzYDJOoaPEvK9WaVPv+7QKk0rfcaLhYPx FnV6wpzDB1Anh02e35R/y4TzJXlJ9mzDzmKP7lI+0J7rUHNJpJyx6FkTJojGCALxKjmm idhA== X-Gm-Message-State: AElRT7HAxASo7cLIJFTpa5bSLjw482Q+6rFR8nsYTr0eyzM6v2mTWm8w olj3U4x/RIYxHT8xinaCtxGZFw== X-Google-Smtp-Source: AIpwx4+WZC0xfbalOt7/O5cDKgrvKX8xuHy94GqSjFpb40e+X9okjWFWsRqnoi1uOLNLjrDPyf66Xg== X-Received: by 10.46.146.4 with SMTP id k4mr486587ljg.21.1522182714167; Tue, 27 Mar 2018 13:31:54 -0700 (PDT) Received: from localhost.localdomain (c-2ec2e1fc-74736162.cust.telenor.se. [46.194.225.252]) by smtp.gmail.com with ESMTPSA id d86sm353055ljd.45.2018.03.27.13.31.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 13:31:53 -0700 (PDT) From: Marcus Folkesson To: ath10k@lists.infradead.org Subject: [PATCH] ath10k: sdio: fix memory leak for probe allocations Date: Tue, 27 Mar 2018 22:31:44 +0200 Message-Id: <20180327203144.8998-1-marcus.folkesson@gmail.com> X-Mailer: git-send-email 2.16.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180327_133206_853050_A6B6595C X-CRM114-Status: UNSURE ( 9.58 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcus Folkesson , linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP These allocations are not freed upon release. When on it; go for managed resources instead. Signed-off-by: Marcus Folkesson --- drivers/net/wireless/ath/ath10k/sdio.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index 07e183f8e57a..005934b8522c 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -1967,7 +1967,7 @@ static int ath10k_sdio_probe(struct sdio_func *func, ar_sdio = ath10k_sdio_priv(ar); ar_sdio->irq_data.irq_proc_reg = - kzalloc(sizeof(struct ath10k_sdio_irq_proc_regs), + devm_kzalloc(ar->dev, sizeof(struct ath10k_sdio_irq_proc_regs), GFP_KERNEL); if (!ar_sdio->irq_data.irq_proc_reg) { ret = -ENOMEM; @@ -1975,17 +1975,17 @@ static int ath10k_sdio_probe(struct sdio_func *func, } ar_sdio->irq_data.irq_en_reg = - kzalloc(sizeof(struct ath10k_sdio_irq_enable_regs), + devm_kzalloc(ar->dev, sizeof(struct ath10k_sdio_irq_enable_regs), GFP_KERNEL); if (!ar_sdio->irq_data.irq_en_reg) { ret = -ENOMEM; - goto err_free_proc_reg; + goto err_core_destroy; } - ar_sdio->bmi_buf = kzalloc(BMI_MAX_CMDBUF_SIZE, GFP_KERNEL); + ar_sdio->bmi_buf = devm_kzalloc(ar->dev, BMI_MAX_CMDBUF_SIZE, GFP_KERNEL); if (!ar_sdio->bmi_buf) { ret = -ENOMEM; - goto err_free_en_reg; + goto err_core_destroy; } ar_sdio->func = func; @@ -2005,7 +2005,7 @@ static int ath10k_sdio_probe(struct sdio_func *func, ar_sdio->workqueue = create_singlethread_workqueue("ath10k_sdio_wq"); if (!ar_sdio->workqueue) { ret = -ENOMEM; - goto err_free_bmi_buf; + goto err_core_destroy; } for (i = 0; i < ATH10K_SDIO_BUS_REQUEST_MAX_NUM; i++) @@ -2021,7 +2021,7 @@ static int ath10k_sdio_probe(struct sdio_func *func, ret = -ENODEV; ath10k_err(ar, "unsupported device id %u (0x%x)\n", dev_id_base, id->device); - goto err_free_bmi_buf; + goto err_core_destroy; } ar->id.vendor = id->vendor; @@ -2050,12 +2050,6 @@ static int ath10k_sdio_probe(struct sdio_func *func, err_free_wq: destroy_workqueue(ar_sdio->workqueue); -err_free_bmi_buf: - kfree(ar_sdio->bmi_buf); -err_free_en_reg: - kfree(ar_sdio->irq_data.irq_en_reg); -err_free_proc_reg: - kfree(ar_sdio->irq_data.irq_proc_reg); err_core_destroy: ath10k_core_destroy(ar);