All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] [PATCH] scsi/gdth.c: Added checks for return values
@ 2006-09-02 12:43 ville palo
  2006-09-02 15:21 ` [KJ] [PATCH] scsi/gdth.c: Added checks for return walter harms
  2006-09-02 16:15 ` [KJ] [PATCH] scsi/gdth.c: Added checks for ville palo
  0 siblings, 2 replies; 3+ messages in thread
From: ville palo @ 2006-09-02 12:43 UTC (permalink / raw)
  To: kernel-janitors


Added checks for return values of the scsi_register().
Without these checks there is a possibility of null 
pointer exceptions.

Signed-off-by: Ville Palo <ville.palo@vi64pa.net>

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 43afd47..6af5fe5 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -4439,13 +4439,14 @@ static int __init gdth_detect(Scsi_Host_
                     virt_ctr = 1;
                     /* register addit. SCSI channels as virtual controllers */
                     for (b = 1; b < ha->bus_cnt + 1; ++b) {
-                        shp = scsi_register(shtp,sizeof(gdth_num_str));
-                        shp->unchecked_isa_dma = 1;
-                        shp->irq = ha->irq;
-                        shp->dma_channel = ha->drq;
-                        gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
-                        NUMDATA(shp)->hanum = (ushort)hanum;
-                        NUMDATA(shp)->busnum = b;
+                        if ((shp = scsi_register(shtp,sizeof(gdth_num_str))) != NULL) {
+                        	shp->unchecked_isa_dma = 1;
+                        	shp->irq = ha->irq;
+                        	shp->dma_channel = ha->drq;
+                        	gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
+                        	NUMDATA(shp)->hanum = (ushort)hanum;
+                        	NUMDATA(shp)->busnum = b;
+			}
                     }
                 }  
 
@@ -4563,13 +4564,14 @@ static int __init gdth_detect(Scsi_Host_
                     virt_ctr = 1;
                     /* register addit. SCSI channels as virtual controllers */
                     for (b = 1; b < ha->bus_cnt + 1; ++b) {
-                        shp = scsi_register(shtp,sizeof(gdth_num_str));
-                        shp->unchecked_isa_dma = 0;
-                        shp->irq = ha->irq;
-                        shp->dma_channel = 0xff;
-                        gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
-                        NUMDATA(shp)->hanum = (ushort)hanum;
-                        NUMDATA(shp)->busnum = b;
+                        if ((shp = scsi_register(shtp,sizeof(gdth_num_str))) != NULL) {
+                        	shp->unchecked_isa_dma = 0;
+                        	shp->irq = ha->irq;
+                        	shp->dma_channel = 0xff;
+                        	gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
+                        	NUMDATA(shp)->hanum = (ushort)hanum;
+                        	NUMDATA(shp)->busnum = b;
+			}
                     }
                 }  
 
@@ -4702,13 +4704,14 @@ static int __init gdth_detect(Scsi_Host_
             virt_ctr = 1;
             /* register addit. SCSI channels as virtual controllers */
             for (b = 1; b < ha->bus_cnt + 1; ++b) {
-                shp = scsi_register(shtp,sizeof(gdth_num_str));
-                shp->unchecked_isa_dma = 0;
-                shp->irq = ha->irq;
-                shp->dma_channel = 0xff;
-                gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
-                NUMDATA(shp)->hanum = (ushort)hanum;
-                NUMDATA(shp)->busnum = b;
+                if ((shp = scsi_register(shtp,sizeof(gdth_num_str))) != NULL) {
+                	shp->unchecked_isa_dma = 0;
+                	shp->irq = ha->irq;
+                	shp->dma_channel = 0xff;
+                	gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
+                	NUMDATA(shp)->hanum = (ushort)hanum;
+                	NUMDATA(shp)->busnum = b;
+		}
             }
         }  
 


_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH] scsi/gdth.c: Added checks for return
  2006-09-02 12:43 [KJ] [PATCH] scsi/gdth.c: Added checks for return values ville palo
@ 2006-09-02 15:21 ` walter harms
  2006-09-02 16:15 ` [KJ] [PATCH] scsi/gdth.c: Added checks for ville palo
  1 sibling, 0 replies; 3+ messages in thread
From: walter harms @ 2006-09-02 15:21 UTC (permalink / raw)
  To: kernel-janitors


i am not sure how the driver behaves but i would expect something like:
shp = scsi_register(shtp,sizeof(gdth_num_str);
if ( shp = NULL) {
	-inform user
	-cleanup debris
}

re,
 wh


ville palo wrote:
> Added checks for return values of the scsi_register().
> Without these checks there is a possibility of null 
> pointer exceptions.
> 
> Signed-off-by: Ville Palo <ville.palo@vi64pa.net>
> 
> diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
> index 43afd47..6af5fe5 100644
> --- a/drivers/scsi/gdth.c
> +++ b/drivers/scsi/gdth.c
> @@ -4439,13 +4439,14 @@ static int __init gdth_detect(Scsi_Host_
>                      virt_ctr = 1;
>                      /* register addit. SCSI channels as virtual controllers */
>                      for (b = 1; b < ha->bus_cnt + 1; ++b) {
> -                        shp = scsi_register(shtp,sizeof(gdth_num_str));
> -                        shp->unchecked_isa_dma = 1;
> -                        shp->irq = ha->irq;
> -                        shp->dma_channel = ha->drq;
> -                        gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
> -                        NUMDATA(shp)->hanum = (ushort)hanum;
> -                        NUMDATA(shp)->busnum = b;
> +                        if ((shp = scsi_register(shtp,sizeof(gdth_num_str))) != NULL) {
> +                        	shp->unchecked_isa_dma = 1;
> +                        	shp->irq = ha->irq;
> +                        	shp->dma_channel = ha->drq;
> +                        	gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
> +                        	NUMDATA(shp)->hanum = (ushort)hanum;
> +                        	NUMDATA(shp)->busnum = b;
> +			}
>                      }
>                  }  
>  
> @@ -4563,13 +4564,14 @@ static int __init gdth_detect(Scsi_Host_
>                      virt_ctr = 1;
>                      /* register addit. SCSI channels as virtual controllers */
>                      for (b = 1; b < ha->bus_cnt + 1; ++b) {
> -                        shp = scsi_register(shtp,sizeof(gdth_num_str));
> -                        shp->unchecked_isa_dma = 0;
> -                        shp->irq = ha->irq;
> -                        shp->dma_channel = 0xff;
> -                        gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
> -                        NUMDATA(shp)->hanum = (ushort)hanum;
> -                        NUMDATA(shp)->busnum = b;
> +                        if ((shp = scsi_register(shtp,sizeof(gdth_num_str))) != NULL) {
> +                        	shp->unchecked_isa_dma = 0;
> +                        	shp->irq = ha->irq;
> +                        	shp->dma_channel = 0xff;
> +                        	gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
> +                        	NUMDATA(shp)->hanum = (ushort)hanum;
> +                        	NUMDATA(shp)->busnum = b;
> +			}
>                      }
>                  }  
>  
> @@ -4702,13 +4704,14 @@ static int __init gdth_detect(Scsi_Host_
>              virt_ctr = 1;
>              /* register addit. SCSI channels as virtual controllers */
>              for (b = 1; b < ha->bus_cnt + 1; ++b) {
> -                shp = scsi_register(shtp,sizeof(gdth_num_str));
> -                shp->unchecked_isa_dma = 0;
> -                shp->irq = ha->irq;
> -                shp->dma_channel = 0xff;
> -                gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
> -                NUMDATA(shp)->hanum = (ushort)hanum;
> -                NUMDATA(shp)->busnum = b;
> +                if ((shp = scsi_register(shtp,sizeof(gdth_num_str))) != NULL) {
> +                	shp->unchecked_isa_dma = 0;
> +                	shp->irq = ha->irq;
> +                	shp->dma_channel = 0xff;
> +                	gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
> +                	NUMDATA(shp)->hanum = (ushort)hanum;
> +                	NUMDATA(shp)->busnum = b;
> +		}
>              }
>          }  
>  
> 
> 
> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors
> 
> 
> 
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH] scsi/gdth.c: Added checks for
  2006-09-02 12:43 [KJ] [PATCH] scsi/gdth.c: Added checks for return values ville palo
  2006-09-02 15:21 ` [KJ] [PATCH] scsi/gdth.c: Added checks for return walter harms
@ 2006-09-02 16:15 ` ville palo
  1 sibling, 0 replies; 3+ messages in thread
From: ville palo @ 2006-09-02 16:15 UTC (permalink / raw)
  To: kernel-janitors

On Sat, 2006-09-02 at 17:21 +0200, walter harms wrote:
> i am not sure how the driver behaves but i would expect something like:
> shp = scsi_register(shtp,sizeof(gdth_num_str);
> if ( shp = NULL) {
> 	-inform user
> 	-cleanup debris
> }
> 

I found it be a common way in this driver:

shp = scsi_register(shtp,sizeof(gdth_ext_str));
if (shp = NULL)
	continue;  

Several same kind of segments can be found in gdth.c.



_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

end of thread, other threads:[~2006-09-02 16:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-02 12:43 [KJ] [PATCH] scsi/gdth.c: Added checks for return values ville palo
2006-09-02 15:21 ` [KJ] [PATCH] scsi/gdth.c: Added checks for return walter harms
2006-09-02 16:15 ` [KJ] [PATCH] scsi/gdth.c: Added checks for ville palo

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.