mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch()
@ 2024-07-24 16:23 Harshit Mogalapalli
  2024-07-24 16:23 ` [PATCH 2/2] usb: typec: tipd: Delete extra semi-colon Harshit Mogalapalli
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Harshit Mogalapalli @ 2024-07-24 16:23 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman, Javier Carrasco,
	Abdel Alkuor, Harshit Mogalapalli, linux-usb, linux-kernel
  Cc: dan.carpenter, kernel-janitors, error27

release_firmware() already frees fw, fix this my moving release_firmware
after the dereference.

Fixes: 916b8e5fa73d ("usb: typec: tipd: add error log to provide firmware name and size")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is found with smatch, only compile tested
---
 drivers/usb/typec/tipd/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index ea768b19a7f1..eb5596e3406a 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -1191,11 +1191,11 @@ 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);
 	}
+	release_firmware(fw);
 
 	return ret;
 };
-- 
2.45.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] usb: typec: tipd: Delete extra semi-colon
  2024-07-24 16:23 [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch() Harshit Mogalapalli
@ 2024-07-24 16:23 ` Harshit Mogalapalli
  2024-07-25  5:45   ` Javier Carrasco
  2024-07-30  8:45   ` Heikki Krogerus
  2024-07-25  5:40 ` [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch() Javier Carrasco
  2024-07-30  8:44 ` Heikki Krogerus
  2 siblings, 2 replies; 6+ messages in thread
From: Harshit Mogalapalli @ 2024-07-24 16:23 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman, Javier Carrasco,
	Abdel Alkuor, Harshit Mogalapalli, linux-usb, linux-kernel
  Cc: dan.carpenter, kernel-janitors, error27

There shouldn't be a ; at the end of the function, delete it.

Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
 drivers/usb/typec/tipd/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index eb5596e3406a..dd51a25480bf 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -1198,7 +1198,7 @@ static int tps6598x_apply_patch(struct tps6598x *tps)
 	release_firmware(fw);
 
 	return ret;
-};
+}
 
 static int cd321x_init(struct tps6598x *tps)
 {
-- 
2.45.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch()
  2024-07-24 16:23 [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch() Harshit Mogalapalli
  2024-07-24 16:23 ` [PATCH 2/2] usb: typec: tipd: Delete extra semi-colon Harshit Mogalapalli
@ 2024-07-25  5:40 ` Javier Carrasco
  2024-07-30  8:44 ` Heikki Krogerus
  2 siblings, 0 replies; 6+ messages in thread
From: Javier Carrasco @ 2024-07-25  5:40 UTC (permalink / raw)
  To: Harshit Mogalapalli, Heikki Krogerus, Greg Kroah-Hartman,
	Abdel Alkuor, linux-usb, linux-kernel
  Cc: dan.carpenter, kernel-janitors, error27

On 24/07/2024 18:23, Harshit Mogalapalli wrote:
> release_firmware() already frees fw, fix this my moving release_firmware
> after the dereference.
> 
> Fixes: 916b8e5fa73d ("usb: typec: tipd: add error log to provide firmware name and size")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> This is found with smatch, only compile tested
> ---
>  drivers/usb/typec/tipd/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index ea768b19a7f1..eb5596e3406a 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1191,11 +1191,11 @@ 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);
>  	}
> +	release_firmware(fw);
>  
>  	return ret;
>  };

Hi Harshit, thanks for the fix.

Reviewed-by: Javier Carrasco <javier.carrasco@wolfvision.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] usb: typec: tipd: Delete extra semi-colon
  2024-07-24 16:23 ` [PATCH 2/2] usb: typec: tipd: Delete extra semi-colon Harshit Mogalapalli
@ 2024-07-25  5:45   ` Javier Carrasco
  2024-07-30  8:45   ` Heikki Krogerus
  1 sibling, 0 replies; 6+ messages in thread
From: Javier Carrasco @ 2024-07-25  5:45 UTC (permalink / raw)
  To: Harshit Mogalapalli, Heikki Krogerus, Greg Kroah-Hartman,
	Abdel Alkuor, linux-usb, linux-kernel
  Cc: dan.carpenter, kernel-janitors, error27

On 24/07/2024 18:23, Harshit Mogalapalli wrote:
> There shouldn't be a ; at the end of the function, delete it.
> 
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
>  drivers/usb/typec/tipd/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index eb5596e3406a..dd51a25480bf 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1198,7 +1198,7 @@ static int tps6598x_apply_patch(struct tps6598x *tps)
>  	release_firmware(fw);
>  
>  	return ret;
> -};
> +}
>  
>  static int cd321x_init(struct tps6598x *tps)
>  {

Reviewed-by: Javier Carrasco <javier.carrasco@wolfvision.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch()
  2024-07-24 16:23 [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch() Harshit Mogalapalli
  2024-07-24 16:23 ` [PATCH 2/2] usb: typec: tipd: Delete extra semi-colon Harshit Mogalapalli
  2024-07-25  5:40 ` [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch() Javier Carrasco
@ 2024-07-30  8:44 ` Heikki Krogerus
  2 siblings, 0 replies; 6+ messages in thread
From: Heikki Krogerus @ 2024-07-30  8:44 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: Greg Kroah-Hartman, Javier Carrasco, Abdel Alkuor, linux-usb,
	linux-kernel, dan.carpenter, kernel-janitors, error27

On Wed, Jul 24, 2024 at 09:23:50AM -0700, Harshit Mogalapalli wrote:
> release_firmware() already frees fw, fix this my moving release_firmware
> after the dereference.
> 
> Fixes: 916b8e5fa73d ("usb: typec: tipd: add error log to provide firmware name and size")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> This is found with smatch, only compile tested
> ---
>  drivers/usb/typec/tipd/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index ea768b19a7f1..eb5596e3406a 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1191,11 +1191,11 @@ 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);
>  	}
> +	release_firmware(fw);
>  
>  	return ret;
>  };
> -- 
> 2.45.2

-- 
heikki

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] usb: typec: tipd: Delete extra semi-colon
  2024-07-24 16:23 ` [PATCH 2/2] usb: typec: tipd: Delete extra semi-colon Harshit Mogalapalli
  2024-07-25  5:45   ` Javier Carrasco
@ 2024-07-30  8:45   ` Heikki Krogerus
  1 sibling, 0 replies; 6+ messages in thread
From: Heikki Krogerus @ 2024-07-30  8:45 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: Greg Kroah-Hartman, Javier Carrasco, Abdel Alkuor, linux-usb,
	linux-kernel, dan.carpenter, kernel-janitors, error27

On Wed, Jul 24, 2024 at 09:23:51AM -0700, Harshit Mogalapalli wrote:
> There shouldn't be a ; at the end of the function, delete it.
> 
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tipd/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index eb5596e3406a..dd51a25480bf 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1198,7 +1198,7 @@ static int tps6598x_apply_patch(struct tps6598x *tps)
>  	release_firmware(fw);
>  
>  	return ret;
> -};
> +}
>  
>  static int cd321x_init(struct tps6598x *tps)
>  {
> -- 
> 2.45.2

-- 
heikki

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-30  8:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-24 16:23 [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch() Harshit Mogalapalli
2024-07-24 16:23 ` [PATCH 2/2] usb: typec: tipd: Delete extra semi-colon Harshit Mogalapalli
2024-07-25  5:45   ` Javier Carrasco
2024-07-30  8:45   ` Heikki Krogerus
2024-07-25  5:40 ` [PATCH 1/2] usb: typec: tipd: Fix dereferencing freeing memory in tps6598x_apply_patch() Javier Carrasco
2024-07-30  8:44 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®