diff mbox series

arm: stm32mp: stm32prog: check result of find_mmc_device

Message ID 20200706132052.1.I28c26381b4f45a78d97ea917280479c10df92e76@changeid
State Accepted
Commit ded48bec0568c7e94d3ef5ea10b13a46d0fd26a6
Delegated to: Patrice Chotard
Headers show
Series arm: stm32mp: stm32prog: check result of find_mmc_device | expand

Commit Message

Patrick DELAUNAY July 6, 2020, 11:20 a.m. UTC
Check result of find_mmc_device() before calling mmc_init().

This patch avoid a data abort when the command try to acces
to sd/mmc device deactivated in device tree.

Fixes: aff4c5dd8265 ("stm32mp: stm32prog: add MMC device")
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Patrice CHOTARD July 28, 2020, 1:29 p.m. UTC | #1
On 7/6/20 1:20 PM, Patrick Delaunay wrote:
> Check result of find_mmc_device() before calling mmc_init().
>
> This patch avoid a data abort when the command try to acces
> to sd/mmc device deactivated in device tree.
>
> Fixes: aff4c5dd8265 ("stm32mp: stm32prog: add MMC device")
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> index c5b8841b23..e4199dbaa5 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> @@ -560,7 +560,7 @@ static int init_device(struct stm32prog_data *data,
>  #ifdef CONFIG_MMC
>  	case STM32PROG_MMC:
>  		mmc = find_mmc_device(dev->dev_id);
> -		if (mmc_init(mmc)) {
> +		if (!mmc || mmc_init(mmc)) {
>  			stm32prog_err("mmc device %d not found", dev->dev_id);
>  			return -ENODEV;
>  		}

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

Patrice
Patrice CHOTARD July 28, 2020, 3:59 p.m. UTC | #2
On 7/28/20 3:29 PM, Patrice CHOTARD wrote:
> On 7/6/20 1:20 PM, Patrick Delaunay wrote:
>> Check result of find_mmc_device() before calling mmc_init().
>>
>> This patch avoid a data abort when the command try to acces
>> to sd/mmc device deactivated in device tree.
>>
>> Fixes: aff4c5dd8265 ("stm32mp: stm32prog: add MMC device")
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>>  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
>> index c5b8841b23..e4199dbaa5 100644
>> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
>> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
>> @@ -560,7 +560,7 @@ static int init_device(struct stm32prog_data *data,
>>  #ifdef CONFIG_MMC
>>  	case STM32PROG_MMC:
>>  		mmc = find_mmc_device(dev->dev_id);
>> -		if (mmc_init(mmc)) {
>> +		if (!mmc || mmc_init(mmc)) {
>>  			stm32prog_err("mmc device %d not found", dev->dev_id);
>>  			return -ENODEV;
>>  		}
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32@st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
Applied to u-boot-stm/master

Thanks

Patrice
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index c5b8841b23..e4199dbaa5 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -560,7 +560,7 @@  static int init_device(struct stm32prog_data *data,
 #ifdef CONFIG_MMC
 	case STM32PROG_MMC:
 		mmc = find_mmc_device(dev->dev_id);
-		if (mmc_init(mmc)) {
+		if (!mmc || mmc_init(mmc)) {
 			stm32prog_err("mmc device %d not found", dev->dev_id);
 			return -ENODEV;
 		}