Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5140368rwe; Tue, 18 Apr 2023 02:37:26 -0700 (PDT) X-Google-Smtp-Source: AKy350YR5XJiTZ+SHUnmEP3ERtsm9tGucO7MycldbwZ3MXbAT5JA64b99AWZjHD7OfvNUxjJPKYE X-Received: by 2002:a17:90b:2382:b0:247:af63:483 with SMTP id mr2-20020a17090b238200b00247af630483mr1342294pjb.46.1681810645938; Tue, 18 Apr 2023 02:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681810645; cv=none; d=google.com; s=arc-20160816; b=WtK/OV3s/634+JqW+t7uCFwhrEYLtt9ZiV0O6+yb02+xAB9IeJpXY3KyrLmHxK/oie RJe8FMQ6RE4rzz/UeOVhBMGc77/Z303P/2cCK1NB7vd+EmHzJZeQGiEEkboN0n4vR27u HNg2gHnJyl1Hjhr5c8C9SGnp6dwBvT33D0K4ycmnMksmzXccxhUXZbG9cdntHo4CC/xV WbAmy+WIKcHDvPpfyM/XhLxi/NjfBYVMy3EKE0qSNB+PLRtHPX355RIJNtReTpWfORN8 0tTPYdugywuG2ePeMaJEl3+N36ztlSk2hV0suSBgIu4syy/++sjdpcCYnAo4iVWiEnBO bIEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kFO6vvqhSOr9qq3Yt/N/Q8e5NErr+jNhARmH/i7ZjoA=; b=BhLTAW4nnA7luHap/l86gFnA9VEmRkSNDlBZReW+nAZ5FU+tOYVFUd0T+zM3UQSldn 5SP6GhuZcPDHl+cPSFsIBAk0zPhSqp/ErKWtgBw/QMJsd7WBEXJtZMCzzN9LwjNAoq61 pVMEYfCNYm5/n8XTp6F+FoPFk9tPj8AWKLyXtSboyMtnflZAcSrhybYEPWooSDYYWxMj AEG2uK8G7eaMAkLWdICdzad0o0/mKVx/Gy45C9ElNn8rb2aknDW5A0SJLvjQW8Nd2tak 2qw8X3GCh7Xo/EV1UddUqVrpZa1GPzt6cJqZqH23lSHdKwQeUaRALRc+Es3tMF7D5tRt A03w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YmsMCJ9O; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020a17090a2b0400b0023755d1a1e1si13124665pjc.28.2023.04.18.02.37.15; Tue, 18 Apr 2023 02:37:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YmsMCJ9O; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231319AbjDRJ2j (ORCPT + 63 others); Tue, 18 Apr 2023 05:28:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231316AbjDRJ2i (ORCPT ); Tue, 18 Apr 2023 05:28:38 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E8ED61B4 for ; Tue, 18 Apr 2023 02:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681810117; x=1713346117; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fbDkro8/rCs1aEMDOqM1IrT828sNwMOOKezHeP13VeU=; b=YmsMCJ9OM/6NqKB2GFPdr/SyVPlqoiaiTGJgey/AlM+sGD2uw2sunAwe wTRejd4/3HBFjWmnUzqWjs/gAWk2pILlvKnF0y7LKNWZnyId1C4E5vkg5 CcCsWNKALeUERbeY3jhZGh4F/Wtq11Y+CFd1WOm8BJHSEzpt4eitQL1lE SRKp7u098j4Q0Oiu5n2x4eh/1RM8iqKzCrOESVVSN9T9DN2no4sdaSD1d gup9EBEmag03FV6FLvLV+yA8+5oxH6f+GnEbDj1ajEYqnheB/qiqpqiq+ 4MOvP+J9OnRL0kA/mk7Lewwut3xZF3Au6Y+jzoNUMQPHiNBTfl0TDcDTd A==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="410341175" X-IronPort-AV: E=Sophos;i="5.99,206,1677571200"; d="scan'208";a="410341175" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 02:28:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="684511224" X-IronPort-AV: E=Sophos;i="5.99,206,1677571200"; d="scan'208";a="684511224" Received: from kadanh-mobl.ger.corp.intel.com (HELO ggreenma-mobl2.lan) ([10.214.234.12]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 02:28:35 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg , Gregory Greenman Subject: [PATCH 05/11] wifi: iwlwifi: mvm: fix potential memory leak Date: Tue, 18 Apr 2023 12:28:08 +0300 Message-Id: <20230418122405.116758321cc4.I8bdbcbb38c89ac637eaa20dda58fa9165b25893a@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230418092814.1438734-1-gregory.greenman@intel.com> References: <20230418092814.1438734-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg If we do get multiple notifications from firmware, then we might have allocated 'notif', but don't free it. Fix that by checking for duplicates before allocation. Fixes: 4da46a06d443 ("wifi: iwlwifi: mvm: Add support for wowlan info notification") Signed-off-by: Johannes Berg Signed-off-by: Gregory Greenman --- drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c index 798a7a1299e1..37aa4676dc94 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c @@ -2722,6 +2722,13 @@ static bool iwl_mvm_wait_d3_notif(struct iwl_notif_wait_data *notif_wait, case WIDE_ID(PROT_OFFLOAD_GROUP, WOWLAN_INFO_NOTIFICATION): { struct iwl_wowlan_info_notif *notif; + if (d3_data->notif_received & IWL_D3_NOTIF_WOWLAN_INFO) { + /* We might get two notifications due to dual bss */ + IWL_DEBUG_WOWLAN(mvm, + "Got additional wowlan info notification\n"); + break; + } + if (wowlan_info_ver < 2) { struct iwl_wowlan_info_notif_v1 *notif_v1 = (void *)pkt->data; @@ -2740,13 +2747,6 @@ static bool iwl_mvm_wait_d3_notif(struct iwl_notif_wait_data *notif_wait, notif = (void *)pkt->data; } - if (d3_data->notif_received & IWL_D3_NOTIF_WOWLAN_INFO) { - /* We might get two notifications due to dual bss */ - IWL_DEBUG_WOWLAN(mvm, - "Got additional wowlan info notification\n"); - break; - } - d3_data->notif_received |= IWL_D3_NOTIF_WOWLAN_INFO; len = iwl_rx_packet_payload_len(pkt); iwl_mvm_parse_wowlan_info_notif(mvm, notif, d3_data->status, -- 2.38.1