mmc: card: fixing an false identification of SANITIZE command
authorYaniv Gardi <ygardi@codeaurora.org>
Wed, 5 Jun 2013 11:13:08 +0000 (14:13 +0300)
committerChris Ball <cjb@laptop.org>
Thu, 27 Jun 2013 15:28:18 +0000 (11:28 -0400)
Inside the routine mmc_blk_ioctl_cmd() the sanitize command is
identified according to the value of bits 16-23 of the argument.

but what happens if a different command is sent, and only by
chance, bits 16-23 contain the value of SANITIZE command ?
In that case a SANITIZE command will be falsely identified.
In order to prevent such a case, the condition is expanded and
now it also checks the opcode itself, and verifies that it is an
MMC_SWITCH opcode.

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/card/block.c

index 59a13fce774e5eb29e30db496c862dc958f9c063..5411bf447369a9cd583c8356c590f588e0bf51ca 100644 (file)
@@ -542,7 +542,8 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
                        goto cmd_rel_host;
        }
 
-       if (MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) {
+       if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) &&
+           (cmd.opcode == MMC_SWITCH)) {
                err = ioctl_do_sanitize(card);
 
                if (err)
This page took 0.0255570000000001 seconds and 5 git commands to generate.