From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752421AbdGEJHW (ORCPT ); Wed, 5 Jul 2017 05:07:22 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:60762 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752058AbdGEJHU (ORCPT ); Wed, 5 Jul 2017 05:07:20 -0400 From: Geert Uytterhoeven To: Ulf Hansson , Linus Walleij Cc: Arnd Bergmann , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/2] mmc: block: Preinitialize ret in mmc_blk_issue_drv_op() Date: Wed, 5 Jul 2017 11:07:16 +0200 Message-Id: <1499245637-28870-1-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, 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. Preinitialize ret to -EINVAL to fix this for current and future callers. Fixes: 0493f6fe5bdee8ac ("mmc: block: Move boot partition locking into a driver op") Signed-off-by: Geert Uytterhoeven --- I assume -EINVAL is the error we want to return here if ioc_count is zero. Or should it return success (zero), like mmc_blk_ioctl_multi_cmd() used to do? --- drivers/mmc/core/block.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 0cfac2d391073922..9472e89af3efa37e 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1175,7 +1175,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) struct mmc_queue_req *mq_rq; struct mmc_card *card = mq->card; struct mmc_blk_data *md = mq->blkdata; - int ret; + int ret = -EINVAL; int i; mq_rq = req_to_mmc_queue_req(req); @@ -1206,7 +1206,6 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) default: pr_err("%s: unknown driver specific operation\n", md->disk->disk_name); - ret = -EINVAL; break; } mq_rq->drv_op_result = ret; -- 2.7.4