public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Dipendra Khadka <kdipendra88@gmail.com>
Cc: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] usb: typec: tipd: Fix dereferencing freed memory 'fw in core.c
Date: Fri, 4 Oct 2024 10:12:07 +0200	[thread overview]
Message-ID: <2024100444-unwound-poppy-97ec@gregkh> (raw)
In-Reply-To: <20240923092625.2673-1-kdipendra88@gmail.com>

On Mon, Sep 23, 2024 at 09:26:24AM +0000, Dipendra Khadka wrote:
> Smatch reported dereferencing freed memory 'fw' in tps6598x_apply_patch().
> 
> Invoking relrease_firmware(fw) just after checking ret.
> 
> Fixes: 916b8e5fa73d ("usb: typec: tipd: add error log to provide firmware name and size")
> Signed-off-by: Dipendra Khadka <kdipendra88@gmail.com>
> ---
> v2:
>  - Updated patch subject.
>  - Updated patch description.
>  - Added Fixes tag.
> v1: 
>  drivers/usb/typec/tipd/core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index ea768b19a7f1..70bf8023ea35 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1191,12 +1191,13 @@ static int tps6598x_apply_patch(struct tps6598x *tps)
>  	dev_info(tps->dev, "Firmware update succeeded\n");
>  
>  release_fw:
> -	release_firmware(fw);
>  	if (ret) {
>  		dev_err(tps->dev, "Failed to write patch %s of %zu bytes\n",
>  			firmware_name, fw->size);
>  	}
>  
> +	relrease_firmware(fw);

Any specific reason why you did not even compile this version of the
patch?

{sigh}


      parent reply	other threads:[~2024-10-04  8:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-23  9:26 [PATCH v2] usb: typec: tipd: Fix dereferencing freed memory 'fw in core.c Dipendra Khadka
2024-09-23  9:47 ` Greg KH
2024-10-04  8:12 ` Greg KH [this message]

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=2024100444-unwound-poppy-97ec@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kdipendra88@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.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