[PATCH] DAC960 fix for NULL dereference in open()
authorDave Olien <dmo@osdl.org>
Sun, 17 Aug 2003 01:42:26 +0000 (18:42 -0700)
committerDoug Ledford <dledford@compaq.xsintricity.com>
Sun, 17 Aug 2003 01:42:26 +0000 (18:42 -0700)
This fixes a problem that's been hidden for a while.

DAC960_open() will try to dereference a NULL pointer if an application
opens (for example) /dev/rd/c0d12 when there has never been a logical
device created for that file.

drivers/block/DAC960.c

index ce64803..2f13a50 100644 (file)
@@ -82,7 +82,7 @@ static int DAC960_open(struct inode *inode, struct file *file)
        } else {
                DAC960_V2_LogicalDeviceInfo_T *i =
                        p->V2.LogicalDeviceInformation[drive_nr];
-               if (i->LogicalDeviceState == DAC960_V2_LogicalDevice_Offline)
+               if (!i || i->LogicalDeviceState == DAC960_V2_LogicalDevice_Offline)
                        return -ENXIO;
        }