linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Coelho, Luciano" <luciano.coelho@intel.com>
To: "kuba@kernel.org" <kuba@kernel.org>,
	"christophe.jaillet@wanadoo.fr" <christophe.jaillet@wanadoo.fr>,
	"kvalo@codeaurora.org" <kvalo@codeaurora.org>,
	"rdunlap@infradead.org" <rdunlap@infradead.org>,
	"davem@davemloft.net" <davem@davemloft.net>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iwlwifi: Fix memory leaks in error handling path
Date: Fri, 12 Nov 2021 09:23:50 +0000	[thread overview]
Message-ID: <6e614fd2baedaad4670c21af8f6dea545218266a.camel@intel.com> (raw)
In-Reply-To: <1504cd7d842d13ddb8244e18004523128d5c9523.1636615284.git.christophe.jaillet@wanadoo.fr>

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@wanadoo.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.

  reply	other threads:[~2021-11-12  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11  7:23 [PATCH] iwlwifi: Fix memory leaks in error handling path Christophe JAILLET
2021-11-12  9:23 ` Coelho, Luciano [this message]
2021-11-22 18:39 ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e614fd2baedaad4670c21af8f6dea545218266a.camel@intel.com \
    --to=luciano.coelho@intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).