]> git.baikalelectronics.ru Git - kernel.git/commit
mmc: block: Initialize ret in mmc_blk_issue_drv_op() for MMC_DRV_OP_IOCTL
authorGeert Uytterhoeven <geert@linux-m68k.org>
Wed, 5 Jul 2017 15:09:41 +0000 (17:09 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 11 Jul 2017 14:27:44 +0000 (16:27 +0200)
commitae49206ca30fbdabd89352ce2782f4327a93b840
tree04664b2ecbd6f02727a10876fd32e5697868b2f9
parent7761576a71655d3f78d0582551ec96f848427308
mmc: block: Initialize ret in mmc_blk_issue_drv_op() for MMC_DRV_OP_IOCTL

With gcc 4.1.2:

    drivers/mmc/core/block.c: In function ‘mmc_blk_issue_drv_op’:
    drivers/mmc/core/block.c:1178: warning: ‘ret’ may be used uninitialized in this function

Indeed, for MMC_DRV_OP_IOCTL, if mq_rq->ioc_count is zero, an
uninitialized value will be stored in mq_rq->drv_op_result and passed to
blk_end_request_all().

Can mq_rq->ioc_count be zero?
  - mmc_blk_ioctl_cmd() sets ioc_count to 1, so this is safe,
  - mmc_blk_ioctl_multi_cmd() obtains ioc_count from user space in
    response to the MMC_IOC_MULTI_CMD ioctl, and does allow zero.

Initialize ret to zero to fix this for current and future callers.

Fixes: fb1a4f3eeb8dbb6e ("mmc: block: Move boot partition locking into a driver op")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/block.c