Re: [PATCH 1/3] mtd: cfi-flash: fail gracefully instead of crashing on NULL page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Feb 28, 2021 at 08:07:05PM +0100, Ahmad Fatoum wrote:
> Until this is fixed, add a comment and have the driver return with an
> error instead of crashing on null pointer dereference if it's mapped to
> zero.
> 
> Signed-off-by: Ahmad Fatoum <ahmad@xxxxxx>
> ---
> Cc: Rouven Czerwinski <r.czerwinski@xxxxxxxxxxxxxx>
> ---
>  drivers/mtd/nor/cfi_flash.c | 4 ++++
>  1 file changed, 4 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
> index 225b03ec3d23..ba0bd1b4ebdd 100644
> --- a/drivers/mtd/nor/cfi_flash.c
> +++ b/drivers/mtd/nor/cfi_flash.c
> @@ -969,6 +969,10 @@ static int cfi_probe_one(struct flash_info *info, int num)
>  		return PTR_ERR(iores);
>  	info->base = IOMEM(iores->start);
>  
> +	/* TODO: either remap memory region or disable NULL pointer page */
> +	if (IS_ENABLED(CONFIG_MMU) && iores->start == 0)
> +		return -EPERM;
> +
>  	ret = flash_detect_size(info);
>  	if (ret) {
>  		dev_warn(info->dev, "## Unknown FLASH on Bank at 0x%p - Size = 0x%08lx = %ld MB\n",
> -- 
> 2.30.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux