Re: [PATCH] mmc: core: don't initialize block size from ext_csd if not present

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

 



On 12/01/21 11:09 pm, Peter Collingbourne wrote:
> If extended CSD was not available, the eMMC driver would incorrectly
> set the block size to 0, as the data_sector_size field of ext_csd
> was never initialized. This issue was exposed by commit 817046ecddbc
> ("block: Align max_hw_sectors to logical blocksize") which caused
> max_sectors and max_hw_sectors to be set to 0 after setting the block
> size to 0, resulting in a kernel panic in bio_split when attempting
> to read from the device. Fix it by only reading the block size from
> ext_csd if it is available.
> 
> Fixes: 817046ecddbc ("block: Align max_hw_sectors to logical blocksize")

I would go with the original commit i.e.

Fixes: a5075eb94837 ("mmc: block: Allow disabling 512B sector size emulation")

> Signed-off-by: Peter Collingbourne <pcc@xxxxxxxxxx>
> Link: https://linux-review.googlesource.com/id/If244d178da4d86b52034459438fec295b02d6e60
> ---
>  drivers/mmc/core/queue.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
> index de7cb0369c30..735cdbf1145c 100644
> --- a/drivers/mmc/core/queue.c
> +++ b/drivers/mmc/core/queue.c
> @@ -20,6 +20,7 @@
>  #include "core.h"
>  #include "card.h"
>  #include "host.h"
> +#include "mmc_ops.h"
>  
>  #define MMC_DMA_MAP_MERGE_SEGMENTS	512
>  
> @@ -384,7 +385,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
>  		     "merging was advertised but not possible");
>  	blk_queue_max_segments(mq->queue, mmc_get_max_segments(host));
>  
> -	if (mmc_card_mmc(card))
> +	if (mmc_card_mmc(card) && mmc_can_ext_csd(card))
>  		block_size = card->ext_csd.data_sector_size;

Might as well be:

	if (mmc_card_mmc(card) && card->ext_csd.data_sector_size)
  		block_size = card->ext_csd.data_sector_size;



>  
>  	blk_queue_logical_block_size(mq->queue, block_size);
> 




[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