diff mbox series

[U-Boot] mmc: fix off-by-one bug in mmc_startup_v4()

Message ID 1519126555-27078-1-git-send-email-al.kochet@gmail.com
State Accepted
Commit 76584e33988fc9f6c80199e04ca6e249baf7289a
Delegated to: Jaehoon Chung
Headers show
Series [U-Boot] mmc: fix off-by-one bug in mmc_startup_v4() | expand

Commit Message

Alexander Kochetkov Feb. 20, 2018, 11:35 a.m. UTC
SD-card with EXT_CSD_REV value 9 will trigger off-by-one
bug while accessing mmc_versions array. The patch fix that.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/mmc/mmc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jaehoon Chung Feb. 21, 2018, 6:37 a.m. UTC | #1
On 02/20/2018 08:35 PM, Alexander Kochetkov wrote:
> SD-card with EXT_CSD_REV value 9 will trigger off-by-one
> bug while accessing mmc_versions array. The patch fix that.

I'm confusing about commit-msg. "SD-card with EXT_CSD_REV"?

Best Regards,
Jaehoon Chung

> 
> Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
> ---
>  drivers/mmc/mmc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 99e2a75..3aa153a 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1974,7 +1974,7 @@ static int mmc_startup_v4(struct mmc *mmc)
>  		return -ENOMEM;
>  	memcpy(mmc->ext_csd, ext_csd, MMC_MAX_BLOCK_LEN);
>  
> -	if (ext_csd[EXT_CSD_REV] > ARRAY_SIZE(mmc_versions))
> +	if (ext_csd[EXT_CSD_REV] >= ARRAY_SIZE(mmc_versions))
>  		return -EINVAL;
>  
>  	mmc->version = mmc_versions[ext_csd[EXT_CSD_REV]];
>
Alexander Kochetkov Feb. 21, 2018, 8:03 a.m. UTC | #2
> 21 февр. 2018 г., в 9:37, Jaehoon Chung <jh80.chung@samsung.com> написал(а):
> 
> I'm confusing about commit-msg. "SD-card with EXT_CSD_REV"?
> 
> Best Regards,
> Jaehoon Chung

I glad to write better, but don’t know. Would this one better?

In future, SD-cards with revision 9 (with REV value 9 inside EXT_CSD register)
will trigger off-by-one bug while accessing mmc_versions array.

Regards,
Alexander.
Jaehoon Chung Feb. 21, 2018, 8:39 a.m. UTC | #3
Hi,

On 02/21/2018 05:03 PM, Alexander Kochetkov wrote:
> 
>> 21 февр. 2018 г., в 9:37, Jaehoon Chung <jh80.chung@samsung.com> написал(а):
>>
>> I'm confusing about commit-msg. "SD-card with EXT_CSD_REV"?
>>
>> Best Regards,
>> Jaehoon Chung
> 
> I glad to write better, but don’t know. Would this one better?
> 
> In future, SD-cards with revision 9 (with REV value 9 inside EXT_CSD register)

Do you mean SD-card or MMC-card? :)
SD doesn't have EXT_CSD register.

- Removed Pantelis's mail account. Instead, add my account, plz.

Best Regards,
Jaehoon Chung

> will trigger off-by-one bug while accessing mmc_versions array.
> 
> Regards,
> Alexander.
> 
>
Alexander Kochetkov Feb. 21, 2018, 8:44 a.m. UTC | #4
> Do you mean SD-card or MMC-card? :)
> SD doesn't have EXT_CSD register.

I see now. MMC-card. So, send v2? or you can simple fix SD with MMC in commit msg.

> 
> - Removed Pantelis's mail account. Instead, add my account, plz.

I took it from here:
https://www.denx.de/wiki/U-Boot/Custodians

Regards,
Alexander.
Jaehoon Chung Feb. 21, 2018, 8:57 a.m. UTC | #5
Hi Alexander,

On 02/21/2018 05:44 PM, Alexander Kochetkov wrote:
> 
>> Do you mean SD-card or MMC-card? :)
>> SD doesn't have EXT_CSD register.
> 
> I see now. MMC-card. So, send v2? or you can simple fix SD with MMC in commit msg.

If you're ok, i will apply yours after changing commit-msg.

Best Regards,
Jaehoon Chung

> 
>>
>> - Removed Pantelis's mail account. Instead, add my account, plz.
> 
> I took it from here:
> https://www.denx.de/wiki/U-Boot/Custodians
> 
> Regards,
> Alexander.
> 
> 
> 
>
Jaehoon Chung Feb. 23, 2018, 7:01 a.m. UTC | #6
On 02/21/2018 05:57 PM, Jaehoon Chung wrote:
> Hi Alexander,
> 
> On 02/21/2018 05:44 PM, Alexander Kochetkov wrote:
>>
>>> Do you mean SD-card or MMC-card? :)
>>> SD doesn't have EXT_CSD register.
>>
>> I see now. MMC-card. So, send v2? or you can simple fix SD with MMC in commit msg.
> 
> If you're ok, i will apply yours after changing commit-msg.

Applied to u-boot-mmc.

Best Regards,
Jaehoon Chung

> 
> Best Regards,
> Jaehoon Chung
> 
>>
>>>
>>> - Removed Pantelis's mail account. Instead, add my account, plz.
>>
>> I took it from here:
>> https://www.denx.de/wiki/U-Boot/Custodians
>>
>> Regards,
>> Alexander.
>>
>>
>>
>>
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
>
diff mbox series

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 99e2a75..3aa153a 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1974,7 +1974,7 @@  static int mmc_startup_v4(struct mmc *mmc)
 		return -ENOMEM;
 	memcpy(mmc->ext_csd, ext_csd, MMC_MAX_BLOCK_LEN);
 
-	if (ext_csd[EXT_CSD_REV] > ARRAY_SIZE(mmc_versions))
+	if (ext_csd[EXT_CSD_REV] >= ARRAY_SIZE(mmc_versions))
 		return -EINVAL;
 
 	mmc->version = mmc_versions[ext_csd[EXT_CSD_REV]];