Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp716776lqt; Tue, 19 Mar 2024 01:14:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaLrTkn5c/KOqTAPm1PK5n9QCxP7w2s4oHRxxPCX430A1Kis9/uvF7z+sAHPo0OzzOKA3q+miNxi0qHpohuhQT8Hk7lucUbO89czF5SQ== X-Google-Smtp-Source: AGHT+IE518IVACcLBBUGB17NibMJ7TH9D+ko0hin+fint8gfVfo08kghcHx8Nr5yb9pYtZmA3Jln X-Received: by 2002:a05:6a20:430c:b0:1a3:50be:b3bb with SMTP id h12-20020a056a20430c00b001a350beb3bbmr2199127pzk.53.1710836048896; Tue, 19 Mar 2024 01:14:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710836048; cv=pass; d=google.com; s=arc-20160816; b=C8Edjfvc0V3LtDCcrREOLyx6yLvV00V+jhCBTPkzJ83GvqPCeUBoJbMqDZogQJE8qc stjD/n0gD0L/27vzt4VpKHk7I9WK+UjpKg+2S2MZKVszf1CCeM4LKfL/81EDr2ZAMf3G ucefkwrfrSaqk62jUd5Yx3tcD4fyFMmTnnOxYsVw0kkwSLIiXoZcaPVxEZ+9WgbS70Sy XK1+T1E8HbesmSU0AhdyXZeOEETdod6lBFqNuNk9Gp+vENvcFh691M9mbDxNKilKq3In BXMQubZopDuFciugnbHJv8o4jhCzoFGzZ70qXu2+gQ9tEi0PDhpDmfqbbvsKitDmpidb Q68Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:organization:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=5lhRKLSm9ZMrAkZrQpGJCcneGVnBuevy1ejxxBgfEQ0=; fh=rLnXSElpTmyjQst8YQ9gHrNGfrW3MGNNyHbA1l7jwik=; b=TRAdr6xGuJtytvkAkw/h3nebRJrTH2k1AECtlKHbsk92a8blgPsTFDNYbmV1ahi/Oe qTIHdeX4B4I+y0hNefhScIUJh3NVcXtCrkoLp2jB6CJdsFnB0eB8FEN5Oq+JdcDEA1kQ ff6CxE6+UDHS4QOo4JXoHgpCLTQqLWZ5/1cTL0LMPZHVt8xFziiSzOEVhvnY9OBrH7rs xx+Wd4eM/QnQuPh9e4HlMLZTtVv+5hcvcrLjPUDmqvtOCyAAn6PVkVO7Hw7/iCiZA7XC pdyiKJWfc7+hhE/S3vCgBF/UkC7mOmhZLy3Y992k9qr3/g24EpgBAZJzxP0l1SUSndJ7 1KcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SIh8Lu7O; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-wireless+bounces-4885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x3-20020a170902ec8300b001def777afb5si8166158plg.334.2024.03.19.01.14.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 01:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-4885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SIh8Lu7O; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-wireless+bounces-4885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9F411B21A14 for ; Tue, 19 Mar 2024 08:12:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 112A77C6C1; Tue, 19 Mar 2024 08:10:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SIh8Lu7O" X-Original-To: linux-wireless@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D6A77C0BA for ; Tue, 19 Mar 2024 08:10:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710835854; cv=none; b=n17NF8yzo7ISDUe3wn3J6NkTV24gigKMRj6NttPrKiQPdqTJDIouxNiOx49EaEsXc+djYIFAlBkpvk2PLAdv+LRQkRYQ4PnD9yA+KAocRsd+f/Gbs0WEUiNjQR2B0HhWnkLQf0OBeAO+qoQjHBQY7KMtGagSmCpTqh6ap8eulW0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710835854; c=relaxed/simple; bh=qz2pvngmX6oK/ewug1vIgUqeObuMjoCkTr8rHSHDR3M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KyCwyvh/QI1J52OIfTdOTDAQX4TOQr9gajoNTHL0vRGLOoENe6TbfuJBe1pkmT4BhulfHvF/iviBcchlnUmBjlRZwRK6koJ0cjrXh3/1Uo4PUuKcHE9vcCeNw+dZOUF7Izrj2XjeGCN7YsLTWafeQquLOaRoMr/FZRLfW6uxJpc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SIh8Lu7O; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710835852; x=1742371852; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qz2pvngmX6oK/ewug1vIgUqeObuMjoCkTr8rHSHDR3M=; b=SIh8Lu7O65OBzzj4xAhFabzrpYhcbU50Ig9zbYRujmePqPgRS3ZnAmzu 0KeAUpOnYfzM8983WHNyH37z3Uo4jz57+tqCTVF1mS50ep8UTlXHPz+sm Fk++OSM30qIqXQYIs9klZaOMA3GmJTwMuXR0ZGO/Amp5yqZzjtmA3MldK N54dNceZJcjwdnGeZ85h1PNO8AN1gE91u+fUERAafmsFXDY+EZnMRSaZ8 +z76ML0UP1XW/TgyDXg+AMG/8v7VuVi5nHm4QMebw3I0/s6i7DXOr2bre O8Jug6tCOJnCbaSzCERYJYL1QWPERCuW+T+zLSZFsngsE6YVR47jBt6ng g==; X-IronPort-AV: E=McAfee;i="6600,9927,11017"; a="5810543" X-IronPort-AV: E=Sophos;i="6.07,136,1708416000"; d="scan'208";a="5810543" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2024 01:10:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,136,1708416000"; d="scan'208";a="18447596" Received: from unknown (HELO WEIS0040.iil.intel.com) ([10.12.217.108]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2024 01:10:50 -0700 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg , Anjaneyulu Subject: [PATCH 05/15] wifi: iwlwifi: mvm: rfi: fix potential response leaks Date: Tue, 19 Mar 2024 10:10:17 +0200 Message-Id: <20240319100755.db2fa0196aa7.I116293b132502ac68a65527330fa37799694b79c@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240319081027.3853611-1-miriam.rachel.korenblit@intel.com> References: <20240319081027.3853611-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited Content-Transfer-Encoding: 8bit From: Johannes Berg If the rx payload length check fails, or if kmemdup() fails, we still need to free the command response. Fix that. Fixes: 21254908cbe9 ("iwlwifi: mvm: add RFI-M support") Co-authored-by: Anjaneyulu Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/mvm/rfi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rfi.c b/drivers/net/wireless/intel/iwlwifi/mvm/rfi.c index 2ecd32bed752..045c862a8fc4 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rfi.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rfi.c @@ -132,14 +132,18 @@ struct iwl_rfi_freq_table_resp_cmd *iwl_rfi_get_freq_table(struct iwl_mvm *mvm) if (ret) return ERR_PTR(ret); - if (WARN_ON_ONCE(iwl_rx_packet_payload_len(cmd.resp_pkt) != resp_size)) + if (WARN_ON_ONCE(iwl_rx_packet_payload_len(cmd.resp_pkt) != + resp_size)) { + iwl_free_resp(&cmd); return ERR_PTR(-EIO); + } resp = kmemdup(cmd.resp_pkt->data, resp_size, GFP_KERNEL); + iwl_free_resp(&cmd); + if (!resp) return ERR_PTR(-ENOMEM); - iwl_free_resp(&cmd); return resp; } -- 2.34.1