mmc: block: ioctl return EINVAL if cmd unknown
authorHuang, Tao <huangtao@rock-chips.com>
Fri, 4 Mar 2016 09:06:12 +0000 (17:06 +0800)
committerGerrit Code Review <gerrit@rock-chips.com>
Fri, 4 Mar 2016 10:21:42 +0000 (18:21 +0800)
We should return -EINVAL if cmd is not MMC_IOC_CMD or MMC_IOC_MULTI_CMD,
otherwise blkdev_roset will return -EPERM.

Android adb, make_block_device_writable ioctl BLKROSET will return error,
make adb remount with error:
remount of /system failed;
couldn't make block device writable: Operation not permitted

Change-Id: I7d0a5727110c0fd9ad301a377e5002eae23f8aed
Fixes: a5f5774c55a2 ("mmc: block: Add new ioctl to send multi commands")
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
drivers/mmc/card/block.c

index 7befdaee555a67bc3b01d5a48cc0f397d2e0ce0a..6efc81ea5dc5d2a6afebb1bf251c5c733e254f3e 100644 (file)
@@ -690,6 +690,11 @@ cmd_err:
 static int mmc_blk_ioctl(struct block_device *bdev, fmode_t mode,
        unsigned int cmd, unsigned long arg)
 {
+#ifdef CONFIG_ARCH_ROCKCHIP
+       if (cmd != MMC_IOC_CMD && cmd != MMC_IOC_MULTI_CMD)
+               return -EINVAL;
+#endif
+
        /*
         * The caller must have CAP_SYS_RAWIO, and must be calling this on the
         * whole block device, not on a partition.  This prevents overspray