All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] rapidio: potential null deref in rio_setup_device()
@ 2011-08-27 10:00 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-08-27 10:00 UTC (permalink / raw)
  To: Matt Porter; +Cc: Alexandre Bounine, open list, kernel-janitors

The "goto cleanup" path can dereference "rswitch" which is NULL here.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
This is sort of embarrassing, I've patched this function before but
missed this.  Hopefully it's right now.

diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 0914f49..882cef9 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -432,7 +432,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
 		/* Assign component tag to device */
 		if (next_comptag >= 0x10000) {
 			pr_err("RIO: Component Tag Counter Overflow\n");
-			goto cleanup;
+			goto out_rdev;
 		}
 		rio_mport_write_config_32(port, destid, hopcount,
 					  RIO_COMPONENT_TAG_CSR, next_comptag);
@@ -518,7 +518,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
 cleanup:
 	if (rio_is_switch(rdev))
 		kfree(rswitch->route_table);
-
+out_rdev:
 	kfree(rdev);
 	return NULL;
 }

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

* [patch] rapidio: potential null deref in rio_setup_device()
@ 2011-08-27 10:00 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-08-27 10:00 UTC (permalink / raw)
  To: Matt Porter; +Cc: Alexandre Bounine, open list, kernel-janitors

The "goto cleanup" path can dereference "rswitch" which is NULL here.

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
This is sort of embarrassing, I've patched this function before but
missed this.  Hopefully it's right now.

diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 0914f49..882cef9 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -432,7 +432,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
 		/* Assign component tag to device */
 		if (next_comptag >= 0x10000) {
 			pr_err("RIO: Component Tag Counter Overflow\n");
-			goto cleanup;
+			goto out_rdev;
 		}
 		rio_mport_write_config_32(port, destid, hopcount,
 					  RIO_COMPONENT_TAG_CSR, next_comptag);
@@ -518,7 +518,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
 cleanup:
 	if (rio_is_switch(rdev))
 		kfree(rswitch->route_table);
-
+out_rdev:
 	kfree(rdev);
 	return NULL;
 }

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

* RE: [patch] rapidio: potential null deref in rio_setup_device()
  2011-08-27 10:00 ` Dan Carpenter
@ 2011-08-29 13:51   ` Bounine, Alexandre
  -1 siblings, 0 replies; 4+ messages in thread
From: Bounine, Alexandre @ 2011-08-29 13:51 UTC (permalink / raw)
  To: Dan Carpenter, Matt Porter; +Cc: open list, kernel-janitors

Dan Carpenter <error27@gmail.com> wrote:

> The "goto cleanup" path can dereference "rswitch" which is NULL here.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> This is sort of embarrassing, I've patched this function before but
> missed this.  Hopefully it's right now.
> 
> diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
> index 0914f49..882cef9 100644
> --- a/drivers/rapidio/rio-scan.c
> +++ b/drivers/rapidio/rio-scan.c
> @@ -432,7 +432,7 @@ static struct rio_dev __devinit
> *rio_setup_device(struct rio_net *net,
>  		/* Assign component tag to device */
>  		if (next_comptag >= 0x10000) {
>  			pr_err("RIO: Component Tag Counter Overflow\n");
> -			goto cleanup;
> +			goto out_rdev;
>  		}
>  		rio_mport_write_config_32(port, destid, hopcount,
>  					  RIO_COMPONENT_TAG_CSR,
next_comptag);
> @@ -518,7 +518,7 @@ static struct rio_dev __devinit
> *rio_setup_device(struct rio_net *net,
>  cleanup:
>  	if (rio_is_switch(rdev))
>  		kfree(rswitch->route_table);

Because rswitch is set not-NULL only for switch devices the check below
can make things simpler: 
  cleanup:
	if (rswitch)
  		kfree(rswitch->route_table);

> -
> +out_rdev:
>  	kfree(rdev);
>  	return NULL;
>  }

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

* RE: [patch] rapidio: potential null deref in rio_setup_device()
@ 2011-08-29 13:51   ` Bounine, Alexandre
  0 siblings, 0 replies; 4+ messages in thread
From: Bounine, Alexandre @ 2011-08-29 13:51 UTC (permalink / raw)
  To: Dan Carpenter, Matt Porter; +Cc: open list, kernel-janitors

Dan Carpenter <error27@gmail.com> wrote:

> The "goto cleanup" path can dereference "rswitch" which is NULL here.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> This is sort of embarrassing, I've patched this function before but
> missed this.  Hopefully it's right now.
> 
> diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
> index 0914f49..882cef9 100644
> --- a/drivers/rapidio/rio-scan.c
> +++ b/drivers/rapidio/rio-scan.c
> @@ -432,7 +432,7 @@ static struct rio_dev __devinit
> *rio_setup_device(struct rio_net *net,
>  		/* Assign component tag to device */
>  		if (next_comptag >= 0x10000) {
>  			pr_err("RIO: Component Tag Counter Overflow\n");
> -			goto cleanup;
> +			goto out_rdev;
>  		}
>  		rio_mport_write_config_32(port, destid, hopcount,
>  					  RIO_COMPONENT_TAG_CSR,
next_comptag);
> @@ -518,7 +518,7 @@ static struct rio_dev __devinit
> *rio_setup_device(struct rio_net *net,
>  cleanup:
>  	if (rio_is_switch(rdev))
>  		kfree(rswitch->route_table);

Because rswitch is set not-NULL only for switch devices the check below
can make things simpler: 
  cleanup:
	if (rswitch)
  		kfree(rswitch->route_table);

> -
> +out_rdev:
>  	kfree(rdev);
>  	return NULL;
>  }

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

end of thread, other threads:[~2011-08-29 13:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-27 10:00 [patch] rapidio: potential null deref in rio_setup_device() Dan Carpenter
2011-08-27 10:00 ` Dan Carpenter
2011-08-29 13:51 ` Bounine, Alexandre
2011-08-29 13:51   ` Bounine, Alexandre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.