lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6e614fd2baedaad4670c21af8f6dea545218266a.camel@intel.com>
Date:   Fri, 12 Nov 2021 09:23:50 +0000
From:   "Coelho, Luciano" <luciano.coelho@...el.com>
To:     "kuba@...nel.org" <kuba@...nel.org>,
        "christophe.jaillet@...adoo.fr" <christophe.jaillet@...adoo.fr>,
        "kvalo@...eaurora.org" <kvalo@...eaurora.org>,
        "rdunlap@...radead.org" <rdunlap@...radead.org>,
        "davem@...emloft.net" <davem@...emloft.net>
CC:     "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
        "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] iwlwifi: Fix memory leaks in error handling path

On Thu, 2021-11-11 at 08:23 +0100, Christophe JAILLET wrote:
> Should an error occur (invalid TLV len or memory allocation failure), the
> memory already allocated in 'reduce_power_data' should be freed before
> returning, otherwise it is leaking.
> 
> Fixes: 9dad325f9d57 ("iwlwifi: support loading the reduced power table from UEFI")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
>  drivers/net/wireless/intel/iwlwifi/fw/uefi.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/wireless/intel/iwlwifi/fw/uefi.c b/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
> index c875bf35533c..009dd4be597b 100644
> --- a/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
> +++ b/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
> @@ -86,6 +86,7 @@ static void *iwl_uefi_reduce_power_section(struct iwl_trans *trans,
>  		if (len < tlv_len) {
>  			IWL_ERR(trans, "invalid TLV len: %zd/%u\n",
>  				len, tlv_len);
> +			kfree(reduce_power_data);
>  			reduce_power_data = ERR_PTR(-EINVAL);
>  			goto out;
>  		}
> @@ -105,6 +106,7 @@ static void *iwl_uefi_reduce_power_section(struct iwl_trans *trans,
>  				IWL_DEBUG_FW(trans,
>  					     "Couldn't allocate (more) reduce_power_data\n");
>  
> +				kfree(reduce_power_data);
>  				reduce_power_data = ERR_PTR(-ENOMEM);
>  				goto out;
>  			}
> @@ -134,6 +136,10 @@ static void *iwl_uefi_reduce_power_section(struct iwl_trans *trans,
>  done:
>  	if (!size) {
>  		IWL_DEBUG_FW(trans, "Empty REDUCE_POWER, skipping.\n");
> +		/* Better safe than sorry, but 'reduce_power_data' should
> +		 * always be NULL if !size.
> +		 */
> +		kfree(reduce_power_data);
>  		reduce_power_data = ERR_PTR(-ENOENT);
>  		goto out;
>  	}

Looks good, thanks!

Kalle, assigning to you for wireless-drivers.


--
Cheers,
Luca.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ