[PATCH 5/9] MCI: imx-esdhc: Fix possible null pointer dereference

Sascha Hauer s.hauer at pengutronix.de
Fri Apr 26 16:54:12 EDT 2013


On Fri, Apr 26, 2013 at 08:41:10PM +0400, Alexander Shiyan wrote:
> 
> Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
> ---
>  drivers/mci/imx-esdhc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
> index 8c2695c..8194b4d 100644
> --- a/drivers/mci/imx-esdhc.c
> +++ b/drivers/mci/imx-esdhc.c
> @@ -450,10 +450,15 @@ static int esdhc_card_present(struct mci_host *mci)
>  static int esdhc_init(struct mci_host *mci, struct device_d *dev)
>  {
>  	struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
> -	struct fsl_esdhc __iomem *regs = host->regs;
> +	struct fsl_esdhc __iomem *regs;
>  	int timeout = 1000;
>  	int ret = 0;
>  
> +	if (!host)
> +		return -EIO;

How should that happen? The mci core should not call this callback with
a NULL pointer, and if it does, there is a bug in the mci core.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list