Skip to contentSkip to conversation

asdf

DISCUSSION Dan Carpenter 2 participants 3 messages Dec 6, 2011 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

There is a new gcc warning in this function:

drivers/mmc/card/block.c:836:18: warning: ‘arg’ may be used uninitialized in this function [-Wuninitialized]

810 /* The sanitize operation is supported at v4.5 only */
811 if (mmc_can_sanitize(card)) {
812 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
813 EXT_CSD_SANITIZE_START, 1, 0);

1) arg is uninitialized here. mmc_switch() can return -EIO.

   814                  goto out;
   815          }
   816  
   817          from = blk_rq_pos(req);
   818          nr = blk_rq_sectors(req);
   819  
   820          if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
   821                  arg = MMC_SECURE_TRIM1_ARG;
   822          else
   823                  arg = MMC_SECURE_ERASE_ARG;
   824  retry:
   825          if (card->quirks & MMC_QUIRK_INAND_CMD38) {
   826                  err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
   827                                   INAND_CMD38_ARG_EXT_CSD,
   828                                   arg == MMC_SECURE_TRIM1_ARG ?
                                         ^^^

3) uninitialized.

   829                                   INAND_CMD38_ARG_SECTRIM1 :
   830                                   INAND_CMD38_ARG_SECERASE,
   831                                   0);
   832                  if (err)
   833                          goto out;
   834          }
   835          err = mmc_erase(card, from, nr, arg);
   836          if (!err && arg == MMC_SECURE_TRIM1_ARG) {
   837                  if (card->quirks & MMC_QUIRK_INAND_CMD38) {
   838                          err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
   839                                           INAND_CMD38_ARG_EXT_CSD,
   840                                           INAND_CMD38_ARG_SECTRIM2,
   841                                           0);

842 if (err)
843 goto out;
844 }
845 err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
846 }
847 out:
848 if (err == -EIO && !mmc_blk_reset(md, card->host, type))
849 goto retry;

2) We could maybe hit the goto retry here if the reset works.

regards,
dan carpenter

#1 lore raw

Re: uninitialized variable in mmc_blk_issue_secdiscard_rq()

Quoted 4 lines · Dan Carpenter

There is a new gcc warning in this function:

drivers/mmc/card/block.c:836:18: warning: ‘arg’ may be used uninitialized in this function [-Wuninitialized]

Sorry for the bad subject. The email escaped before it should have.

Same thing for "nr" and "from".

drivers/mmc/card/block.c:835:6: warning: ‘nr’ may be used uninitialized in this function [-Wuninitialized] drivers/mmc/card/block.c:835:6: warning: ‘from’ may be used uninitialized in this function [-Wuninitialized]

regards,
dan carpenter

#2 lore raw
In reply to Dan Carpenter

Hi

Yes possible scenario, it should be changed like this.

out:

        if (err == -EIO) {
                int ret = !mmc_blk_reset(md, card->host, type);
                if (ret && !mmc_can_sanitize(card))
                        goto retry;
        }

anyway, I will find the more fancy way.

Thank you for pointing out.

BR,
Kyungmin Park

Quoted 65 lines · Dan Carpenter

There is a new gcc warning in this function:

drivers/mmc/card/block.c:836:18: warning: ‘arg’ may be used uninitialized in this function [-Wuninitialized]

810 /* The sanitize operation is supported at v4.5 only */
811 if (mmc_can_sanitize(card)) {
812 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
813 EXT_CSD_SANITIZE_START, 1, 0);

1) arg is uninitialized here. mmc_switch() can return -EIO.

   814                  goto out;
   815          }
   816
   817          from = blk_rq_pos(req);
   818          nr = blk_rq_sectors(req);
   819
   820          if (mmc_can_trim(card) && !mmc_erase_group_aligned(card,
from, nr))
   821                  arg = MMC_SECURE_TRIM1_ARG;
   822          else
   823                  arg = MMC_SECURE_ERASE_ARG;
   824  retry:
   825          if (card->quirks & MMC_QUIRK_INAND_CMD38) {
   826                  err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
   827                                   INAND_CMD38_ARG_EXT_CSD,
   828                                   arg == MMC_SECURE_TRIM1_ARG ?
                                         ^^^

3) uninitialized.

   829                                   INAND_CMD38_ARG_SECTRIM1 :
   830                                   INAND_CMD38_ARG_SECERASE,
   831                                   0);
   832                  if (err)
   833                          goto out;
   834          }
   835          err = mmc_erase(card, from, nr, arg);
   836          if (!err && arg == MMC_SECURE_TRIM1_ARG) {
   837                  if (card->quirks & MMC_QUIRK_INAND_CMD38) {
   838                          err = mmc_switch(card,
EXT_CSD_CMD_SET_NORMAL,
   839                                           INAND_CMD38_ARG_EXT_CSD,
   840                                           INAND_CMD38_ARG_SECTRIM2,
   841                                           0);
   842                          if (err)
   843                                  goto out;
   844                  }
   845                  err = mmc_erase(card, from, nr,
MMC_SECURE_TRIM2_ARG);
   846          }
   847  out:
   848          if (err == -EIO && !mmc_blk_reset(md, card->host, type))
   849                  goto retry;

2) We could maybe hit the goto retry here if the reset works.

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html