From patchwork Wed Dec 23 08:51:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1420027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D16x85nHFz9sTc; Wed, 23 Dec 2020 20:15:08 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ks0EX-0004mF-Bg; Wed, 23 Dec 2020 09:15:01 +0000 Received: from mail-pf1-f182.google.com ([209.85.210.182]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1ks07M-0005fg-2o for kernel-team@lists.ubuntu.com; Wed, 23 Dec 2020 09:07:36 +0000 Received: by mail-pf1-f182.google.com with SMTP id c12so9996157pfo.10 for ; Wed, 23 Dec 2020 01:07:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fUtzBc01ITggR/rR2T3rwcnopejOB8wbO8oHwU4zGz0=; b=CcpHlC+PLO+MlXXmOki7QTfODP8uoNPCvysi29u1lJGKfn4/u9E2GTOcd5Z2b4AtrT 7RK9MhRZnb4WRqzDH8UhJL0GVYrkf74ekLfInnooDuBlgOfgdrVhUoQWMPJRy70CFzlK Vcd/UsEHtF+JR/9Ugu1bQnbdiafwlY4R5aRbxGnX40/iwbEo4J6doQuSYJdSu9q/xNQN 5mwuvLbJtV9hLs7Wh1O7PK7eI2kZvuHWhvLx/KEltqjdLYOL3wQ23TjdxoBJadP8Cldx e/4BAvt2j0dBqPMHDWHz6okJwMU+gdLVeyDmnsDIT7++kpTySS9YnfTXtGjByAtYegyc QN8Q== X-Gm-Message-State: AOAM532Rxkt7p9OpK053KMx50fsAteHTd8jiQuQrOiZfzkg++gdBFbzU z1ts0dX7U+/wqw+t1SUqSf4DoRKp4/1oPZ8O X-Google-Smtp-Source: ABdhPJwKwm0qPEQTcul2wvCP/pw2MVK7vao7il3rjPWaeO7pQvSqRDfl6Aw5RvKLvGBNqxDk3qXCpQ== X-Received: by 2002:a63:184c:: with SMTP id 12mr24039761pgy.381.1608714440520; Wed, 23 Dec 2020 01:07:20 -0800 (PST) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id f29sm23118225pfk.32.2020.12.23.01.07.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 01:07:19 -0800 (PST) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 354/379][SRU][OEM-5.6] ath11k: Fix memory leak on error path Date: Wed, 23 Dec 2020 16:51:27 +0800 Message-Id: <20201223085152.554896-355-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223085152.554896-1-vicamo.yang@canonical.com> References: <20201223085152.554896-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.182; envelope-from=vicamo@gmail.com; helo=mail-pf1-f182.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Alex Dewar BugLink: https://bugs.launchpad.net/bugs/1879633 In ath11k_mac_setup_iface_combinations(), if memory cannot be assigned for the variable limits, then the memory assigned to combinations will be leaked. Fix this. Addresses-Coverity-ID: 1497534 ("Resource leaks") Fixes: 2626c269702e ("ath11k: add interface_modes to hw_params") Signed-off-by: Alex Dewar Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201004100218.311653-2-alex.dewar90@gmail.com (cherry picked from commit 8431350eee2e27ae60f5250e0437ab298329070e) Signed-off-by: You-Sheng Yang --- 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);