diff mbox series

mmc: sdhci-of-arasan: Add NULL check for data field

Message ID 1652339993-27280-1-git-send-email-lakshmi.sai.krishna.potthuri@xilinx.com
State New
Headers show
Series mmc: sdhci-of-arasan: Add NULL check for data field | expand

Commit Message

Sai Krishna Potthuri May 12, 2022, 7:19 a.m. UTC
Add NULL check for data field retrieved from of_device_get_match_data()
before dereferencing the data.
Addresses-coverity: CID 305057:Dereference null return value (NULL_RETURNS)

Signed-off-by: Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>
---
 drivers/mmc/host/sdhci-of-arasan.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Adrian Hunter May 12, 2022, 11:47 a.m. UTC | #1
On 12/05/22 10:19, Sai Krishna Potthuri wrote:
> Add NULL check for data field retrieved from of_device_get_match_data()
> before dereferencing the data.
> Addresses-coverity: CID 305057:Dereference null return value (NULL_RETURNS)
> 
> Signed-off-by: Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-of-arasan.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
> index 6a2e5a468424..757801dfc308 100644
> --- a/drivers/mmc/host/sdhci-of-arasan.c
> +++ b/drivers/mmc/host/sdhci-of-arasan.c
> @@ -1577,6 +1577,9 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
>  	const struct sdhci_arasan_of_data *data;
>  
>  	data = of_device_get_match_data(dev);
> +	if (!data)
> +		return -EINVAL;
> +
>  	host = sdhci_pltfm_init(pdev, data->pdata, sizeof(*sdhci_arasan));
>  
>  	if (IS_ERR(host))
Ulf Hansson May 16, 2022, 1:55 p.m. UTC | #2
On Thu, 12 May 2022 at 09:20, Sai Krishna Potthuri
<lakshmi.sai.krishna.potthuri@xilinx.com> wrote:
>
> Add NULL check for data field retrieved from of_device_get_match_data()
> before dereferencing the data.
> Addresses-coverity: CID 305057:Dereference null return value (NULL_RETURNS)
>
> Signed-off-by: Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci-of-arasan.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
> index 6a2e5a468424..757801dfc308 100644
> --- a/drivers/mmc/host/sdhci-of-arasan.c
> +++ b/drivers/mmc/host/sdhci-of-arasan.c
> @@ -1577,6 +1577,9 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
>         const struct sdhci_arasan_of_data *data;
>
>         data = of_device_get_match_data(dev);
> +       if (!data)
> +               return -EINVAL;
> +
>         host = sdhci_pltfm_init(pdev, data->pdata, sizeof(*sdhci_arasan));
>
>         if (IS_ERR(host))
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index 6a2e5a468424..757801dfc308 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -1577,6 +1577,9 @@  static int sdhci_arasan_probe(struct platform_device *pdev)
 	const struct sdhci_arasan_of_data *data;
 
 	data = of_device_get_match_data(dev);
+	if (!data)
+		return -EINVAL;
+
 	host = sdhci_pltfm_init(pdev, data->pdata, sizeof(*sdhci_arasan));
 
 	if (IS_ERR(host))