From: Jan Beulich Date: Fri, 8 Jul 2011 12:23:47 +0000 (+0100) Subject: blkfront: avoid NULL de-reference in CDROM ioctl handling X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1819eb3250466b2919f54dfe383331612483a557;p=legacy%2Flinux-2.6.18-xen.git blkfront: avoid NULL de-reference in CDROM ioctl handling 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 --- diff --git a/drivers/xen/blkfront/blkfront.c b/drivers/xen/blkfront/blkfront.c index 617c7478..c5a648a9 100644 --- a/drivers/xen/blkfront/blkfront.c +++ b/drivers/xen/blkfront/blkfront.c @@ -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) {