linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: card: move variable initialization earlier
@ 2012-03-23  9:32 Linus Walleij
  2012-04-01  4:07 ` Chris Ball
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2012-03-23  9:32 UTC (permalink / raw)
  To: linux-mmc, Chris Ball; +Cc: Linus Walleij, Ulf Hansson, Rabin Vincent

I was pretty tired of seeing these in my kernel compiles:

drivers/mmc/card/block.c: In function ‘mmc_blk_issue_secdiscard_rq’:
drivers/mmc/card/block.c:911:18: warning: ‘arg’ may be used uninitialized in this function [-Wuninitialized]
drivers/mmc/card/block.c:910:6: warning: ‘nr’ may be used uninitialized in this function [-Wuninitialized]
drivers/mmc/card/block.c:910:6: warning: ‘from’ may be used uninitialized in this function [-Wuninitialized]

The problem stems from the code path in
mmc_blk_issue_secdiscard_rq() where mmc_switch()
with EXT_CSD_SANITIZE_START may return -EIO and fall back
to using the default trim operations instead. At this point
the variables needed for the fallback will be uninitialized.

Cc: Ulf Hansson <ulf.hansson@stericsson.com>
Cc: Rabin Vincent <rabin@rab.in>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
I don't know if this is the actual intention - maybe we
should just fail the call entirely if the sanitize command
fails?
---
 drivers/mmc/card/block.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index c6a383d..2741d93 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -877,6 +877,14 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
 	unsigned int from, nr, arg;
 	int err = 0, type = MMC_BLK_SECDISCARD;
 
+	from = blk_rq_pos(req);
+	nr = blk_rq_sectors(req);
+
+	if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
+		arg = MMC_SECURE_TRIM1_ARG;
+	else
+		arg = MMC_SECURE_ERASE_ARG;
+
 	if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
 		err = -EOPNOTSUPP;
 		goto out;
@@ -889,13 +897,6 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
 		goto out;
 	}
 
-	from = blk_rq_pos(req);
-	nr = blk_rq_sectors(req);
-
-	if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
-		arg = MMC_SECURE_TRIM1_ARG;
-	else
-		arg = MMC_SECURE_ERASE_ARG;
 retry:
 	if (card->quirks & MMC_QUIRK_INAND_CMD38) {
 		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-04  6:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-23  9:32 [PATCH] mmc: card: move variable initialization earlier Linus Walleij
2012-04-01  4:07 ` Chris Ball
2012-04-03  8:40   ` Adrian Hunter
2012-04-03 10:57     ` Linus Walleij
2012-04-03 16:55     ` Luca Porzio (lporzio)
2012-04-04  6:20       ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).