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: 10311597 X-Patchwork-Delegate: kvalo@adurom.com 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 B8AFF60212 for ; Tue, 27 Mar 2018 20:32:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ED0E2981B for ; Tue, 27 Mar 2018 20:32:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EDA72972F; Tue, 27 Mar 2018 20:32:47 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 281EA29EB2 for ; Tue, 27 Mar 2018 20:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751253AbeC0Ub4 (ORCPT ); Tue, 27 Mar 2018 16:31:56 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:46242 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeC0Ubz (ORCPT ); Tue, 27 Mar 2018 16:31:55 -0400 Received: by mail-lf0-f67.google.com with SMTP id j68-v6so255460lfg.13 for ; Tue, 27 Mar 2018 13:31:55 -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=sKeh+Y62UHJntR6i3We64sIJEKiNtjXci5AMwAtp0ZwbynGnWD+xNJcjKBwAXX+ICn mLjHSCW6d7JybgM7JC99j2gHufGxPa5U1T3L/sB8fXJQpYARfgnN1v79KKbEEqRivnri EL50Y4tcoMtLTMnUGhAgvjLFihy0CmaY9SryLorlB895FWVgGnlGLBNLPRaKWawd5ay7 0wyYBsWWBIBeZn3K+XKUAeklV3M5EN7/zLm3o+3C6na8CHb+6IvgFpn0aD1j+Ublay/J YX/Gn6bi8853TLgIaxFcmE87rfCt9CS8xu/umVYqcrnoJPGGI8vYFG8cJtddAz5oGOdo GT3A== X-Gm-Message-State: AElRT7FmbckUE0PUT5DFsrfgoB3P0fX6AwTuN467gbv/oYK5idNd+9W/ 2kWgbYJEKHDpxwyxcKW2TNQ= 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 Cc: linux-wireless@vger.kernel.org, Marcus Folkesson 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 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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);