block/ioctl: prefer different overflow check
[linux-2.6-block.git] / block / ioctl.c
index 0c76137adcaaa5b9d212d789291d681c23c064f6..06ff3023e2a133c3fb4449b6971286939b9ebf48 100644 (file)
@@ -33,7 +33,7 @@ static int blkpg_do_ioctl(struct block_device *bdev,
        if (op == BLKPG_DEL_PARTITION)
                return bdev_del_partition(disk, p.pno);
 
-       if (p.start < 0 || p.length <= 0 || p.start + p.length < 0)
+       if (p.start < 0 || p.length <= 0 || LLONG_MAX - p.length < p.start)
                return -EINVAL;
        /* Check that the partition is aligned to the block size */
        if (!IS_ALIGNED(p.start | p.length, bdev_logical_block_size(bdev)))