[PATCH] mmc:fix a bug when max_discard is 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The original purpose of the code I fix is to choose max_trim as the final
parameter instead of max_discard if max_trim is less than max_discard. But
there is a uncommon case that max_discard is 0 because max_discard is
overflow the maximum threshold. In this case, we should still choose
max_trim instead of max_discard, however, in the original code(if(max_trim
 < max_discard)), the conditio is false when max_discard is 0. So I fix it
by add "|| max_discard == 0" to cover this case.

Signed-off-by: Jiong Wu <Lohengrin1024@xxxxxxxxx>
---
 drivers/mmc/core/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 5bd58b9..7b1bd95 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2383,7 +2383,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
 	max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG);
 	if (max_discard && mmc_can_trim(card)) {
 		max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG);
-		if (max_trim < max_discard)
+		if (max_trim < max_discard || max_discard == 0)
 			max_discard = max_trim;
 	} else if (max_discard < card->erase_size) {
 		max_discard = 0;
-- 
2.7.4




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux