ublk: fix command op code check
authorMing Lei <ming.lei@redhat.com>
Fri, 5 May 2023 15:31:42 +0000 (23:31 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 12 May 2023 15:09:06 +0000 (09:09 -0600)
In case of CONFIG_BLKDEV_UBLK_LEGACY_OPCODES, type of cmd opcode could
be 0 or 'u'; and type can only be 'u' if CONFIG_BLKDEV_UBLK_LEGACY_OPCODES
isn't set.

So fix the wrong check.

Fixes: 2d786e66c966 ("block: ublk: switch to ioctl command encoding")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230505153142.1258336-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c

index c7331f51975031aaf8f2d838cd7a37701651ea4b..c7ed5d69e9eee2545c0f4458ce6f4a1847060cde 100644 (file)
@@ -1281,7 +1281,7 @@ static inline int ublk_check_cmd_op(u32 cmd_op)
 {
        u32 ioc_type = _IOC_TYPE(cmd_op);
 
-       if (IS_ENABLED(CONFIG_BLKDEV_UBLK_LEGACY_OPCODES) && ioc_type != 'u')
+       if (!IS_ENABLED(CONFIG_BLKDEV_UBLK_LEGACY_OPCODES) && ioc_type != 'u')
                return -EOPNOTSUPP;
 
        if (ioc_type != 'u' && ioc_type != 0)