From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] [PATCH] scsi/gdth.c: Added checks for return
Date: Sat, 02 Sep 2006 15:21:39 +0000 [thread overview]
Message-ID: <44F9A183.5000001@bfs.de> (raw)
In-Reply-To: <1157201011.9695.17.camel@localhost.localdomain>
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
next prev parent reply other threads:[~2006-09-02 15:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-02 12:43 [KJ] [PATCH] scsi/gdth.c: Added checks for return values ville palo
2006-09-02 15:21 ` walter harms [this message]
2006-09-02 16:15 ` [KJ] [PATCH] scsi/gdth.c: Added checks for ville palo
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=44F9A183.5000001@bfs.de \
--to=wharms@bfs.de \
--cc=kernel-janitors@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 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.