Skip to contentSkip to conversation

linux-2.6.18/blkfront: avoid NULL de-reference in CDROM ioctl handling

PATCH New Jan Beulich 1 participant 1 message Jul 8, 2011 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-2.6.18/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.

drivers/xen/blkfront/blkfront.c +3 -4
@@ -566,12 +566,11 @@ int blkif_ioctl(struct block_device *bd,
 				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) {

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.

drivers/xen/blkfront/blkfront.c +3 -4
@@ -566,12 +566,11 @@ int blkif_ioctl(struct block_device *bd,
 				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) {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel