]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
blkfront: avoid NULL de-reference in CDROM ioctl handling
authorJan Beulich <jbeulich@novell.com>
Fri, 8 Jul 2011 12:23:47 +0000 (13:23 +0100)
committerJan Beulich <jbeulich@novell.com>
Fri, 8 Jul 2011 12:23:47 +0000 (13:23 +0100)
Just like already done in the default case, for CDROM_GET_CAPABILITY
info->gd should not be blindly de-referenced, as the ioctl can be
called prior to full device setup having completed.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
drivers/xen/blkfront/blkfront.c

index 617c74783abc775e9cef1795ee2414107825e6d3..c5a648a9c353afdae88356e0998f148b60f387ab 100644 (file)
@@ -566,12 +566,11 @@ int blkif_ioctl(struct inode *inode, struct file *filep,
                                return -EFAULT;
                return 0;
 
-       case CDROM_GET_CAPABILITY: {
-               struct gendisk *gd = info->gd;
-               if (gd->flags & GENHD_FL_CD)
+       case CDROM_GET_CAPABILITY:
+               if (info->gd && (info->gd->flags & GENHD_FL_CD))
                        return 0;
                return -EINVAL;
-       }
+
        default:
                if (info->mi && info->gd) {
                        switch (info->mi->major) {