diff mbox

[1/7] mmc: sdhci-pltfm: bail out if register resource is too small

Message ID 1460600990-10993-2-git-send-email-yamada.masahiro@socionext.com (mailing list archive)
State New, archived
Headers show

Commit Message

Masahiro Yamada April 14, 2016, 2:29 a.m. UTC
This code checks the resource size and displays an error message if
it is too small, but still moves forward.  Let is fail in that case.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mmc/host/sdhci-pltfm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Adrian Hunter April 19, 2016, 11:32 a.m. UTC | #1
On 14/04/16 05:29, Masahiro Yamada wrote:
> This code checks the resource size and displays an error message if
> it is too small, but still moves forward.  Let is fail in that case.

is -> it

How do you know there aren't drivers that actually have a smaller size?

One that might not is sdhci-dove which appears to sidestep some registers in
sdhci_dove_readw().


> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
>  drivers/mmc/host/sdhci-pltfm.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
> index 072bb27..7d12203 100644
> --- a/drivers/mmc/host/sdhci-pltfm.c
> +++ b/drivers/mmc/host/sdhci-pltfm.c
> @@ -127,8 +127,11 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
>  		goto err;
>  	}
>  
> -	if (resource_size(iomem) < 0x100)
> +	if (resource_size(iomem) < 0x100) {
>  		dev_err(&pdev->dev, "Invalid iomem size!\n");
> +		ret = -EINVAL;
> +		goto err;
> +	}
>  
>  	host = sdhci_alloc_host(&pdev->dev,
>  		sizeof(struct sdhci_pltfm_host) + priv_size);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada April 19, 2016, 11:46 a.m. UTC | #2
Hi Adrian,


2016-04-19 20:32 GMT+09:00 Adrian Hunter <adrian.hunter@intel.com>:
> On 14/04/16 05:29, Masahiro Yamada wrote:
>> This code checks the resource size and displays an error message if
>> it is too small, but still moves forward.  Let is fail in that case.
>
> is -> it
>
> How do you know there aren't drivers that actually have a smaller size?

No, I do not know.

This is an error message, so I think it should fail in that case.


Maybe, can we drop this check completely?
Adrian Hunter April 19, 2016, 1:28 p.m. UTC | #3
On 19/04/16 14:46, Masahiro Yamada wrote:
> Hi Adrian,
> 
> 
> 2016-04-19 20:32 GMT+09:00 Adrian Hunter <adrian.hunter@intel.com>:
>> On 14/04/16 05:29, Masahiro Yamada wrote:
>>> This code checks the resource size and displays an error message if
>>> it is too small, but still moves forward.  Let is fail in that case.
>>
>> is -> it
>>
>> How do you know there aren't drivers that actually have a smaller size?
> 
> No, I do not know.
> 
> This is an error message, so I think it should fail in that case.
> 
> 
> Maybe, can we drop this check completely?

Yes, I think so.

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index 072bb27..7d12203 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -127,8 +127,11 @@  struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
 		goto err;
 	}
 
-	if (resource_size(iomem) < 0x100)
+	if (resource_size(iomem) < 0x100) {
 		dev_err(&pdev->dev, "Invalid iomem size!\n");
+		ret = -EINVAL;
+		goto err;
+	}
 
 	host = sdhci_alloc_host(&pdev->dev,
 		sizeof(struct sdhci_pltfm_host) + priv_size);