From patchwork Tue Oct 6 17:42:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 11819025 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 CBD4B139F for ; Tue, 6 Oct 2020 17:42:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8DD720760 for ; Tue, 6 Oct 2020 17:42:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbgJFRmc (ORCPT ); Tue, 6 Oct 2020 13:42:32 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:53549 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbgJFRmc (ORCPT ); Tue, 6 Oct 2020 13:42:32 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kPqyn-0007TZ-M2; Tue, 06 Oct 2020 17:42:25 +0000 From: Colin King To: Kalle Valo , "David S . Miller" , Jakub Kicinski , ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] ath11k: fix memory leak of 'combinations' Date: Tue, 6 Oct 2020 18:42:25 +0100 Message-Id: <20201006174225.545919-1-colin.king@canonical.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Colin Ian King Currently the error return path when 'limits' fails to allocate does not free the memory allocated for 'combinations'. Fix this by adding a kfree before returning. Addresses-Coverity: ("Resource leak") Fixes: 2626c269702e ("ath11k: add interface_modes to hw_params") Signed-off-by: Colin Ian King --- drivers/net/wireless/ath/ath11k/mac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 3f63a7bd6b59..7f8dd47d2333 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -6041,8 +6041,10 @@ static int ath11k_mac_setup_iface_combinations(struct ath11k *ar) n_limits = 2; limits = kcalloc(n_limits, sizeof(*limits), GFP_KERNEL); - if (!limits) + if (!limits) { + kfree(combinations); return -ENOMEM; + } limits[0].max = 1; limits[0].types |= BIT(NL80211_IFTYPE_STATION);