On Fri, Feb 25, 2005 at 01:26:50PM -0800, Mark Haverkamp wrote:
> I wonder if it wouldn't be better to just check the error return before
> the index value.

It's all the same to me.

In drivers/scsi/sd.c:sd_probe:

        int index;
        ...
        spin_lock(&sd_index_lock);
        error = idr_get_new(&sd_index_idr, NULL, &index);
        spin_unlock(&sd_index_lock);

        if (index >= SD_MAX_DISKS)
                error = -EBUSY;
        if (error)
                goto out_put;

Note that if idr_get_new() fails, index remains uninitialized.  If it
happens to be >= SD_MAX_DISKS, the error returned from idr_get_new will
be clobbered.  Patch initializes checks error code from idr_get_new
before accessing index.

Signed-off-by: Kenn Humborg <[EMAIL PROTECTED]>

--- src/drivers/scsi/sd.c-2.6.10        2005-02-25 21:02:17.000000000 +0000
+++ src/drivers/scsi/sd.c       2005-03-01 23:21:04.539648136 +0000
@@ -1438,7 +1438,7 @@
        error = idr_get_new(&sd_index_idr, NULL, &index);
        spin_unlock(&sd_index_lock);
 
-       if (index >= SD_MAX_DISKS)
+       if (!error && (index >= SD_MAX_DISKS))
                error = -EBUSY;
        if (error)
                goto out_put;



-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to