OSDN Git Service

Staging: comedi: comedi_open: Fix null pointer dereference.
authorIan Abbott <abbotti@mev.co.uk>
Mon, 9 Feb 2009 16:51:38 +0000 (16:51 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 3 Apr 2009 21:53:52 +0000 (14:53 -0700)
This can happen if other minor devices are used.

From: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: David Schleef <ds@schleef.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/comedi/comedi_fops.c

index 6867b09..fa5ef2e 100644 (file)
@@ -1760,7 +1760,8 @@ static int comedi_open(struct inode *inode, struct file *file)
        const unsigned minor = iminor(inode);
        struct comedi_device_file_info *dev_file_info =
            comedi_get_device_file_info(minor);
-       comedi_device *dev = dev_file_info->device;
+       comedi_device *dev = dev_file_info ? dev_file_info->device : NULL;
+
        if (dev == NULL) {
                DPRINTK("invalid minor number\n");
                return -ENODEV;