[PATCH u-boot-marvell] arm: mvebu: turris_omnia: fix leaked mtd device

Pali Rohár pali at kernel.org
Sat Sep 25 18:05:44 CEST 2021


On Saturday 25 September 2021 02:49:18 Marek Behún wrote:
> From: Marek Behún <marek.behun at nic.cz>
> 
> After getting MTD device via get_mtd_device_nm(), we need to put it with
> put_mtd_device(), otherwise we get
> 
>   Removing MTD device #0 (mx25l6405d) with use count 1
> 
> before booting kernel.
> 
> Signed-off-by: Marek Behún <marek.behun at nic.cz>

Reviewed-by: Pali Rohár <pali at kernel.org>
Tested-by: Pali Rohár <pali at kernel.org>
Fixes: 92f36c8e74c1 ("arm: mvebu: turris_omnia: fixup MTD partitions in Linux' DTB")

Above commit was introduced in v2021.10-rc1, so I think this fixup
should go into v2021.10.

Stefan, what do you think?

> ---
>  board/CZ.NIC/turris_omnia/turris_omnia.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
> index bac78af04e..a48e1f5c30 100644
> --- a/board/CZ.NIC/turris_omnia/turris_omnia.c
> +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
> @@ -647,10 +647,13 @@ int ft_board_setup(void *blob, struct bd_info *bd)
>  	if (!fixup_mtd_partitions(blob, node, mtd))
>  		goto fail;
>  
> +	put_mtd_device(mtd);
>  	return 0;
>  
>  fail:
>  	printf("Failed fixing SPI NOR partitions!\n");
> +	if (!IS_ERR_OR_NULL(mtd))
> +		put_mtd_device(mtd);
>  	return 0;
>  }
>  #endif
> -- 
> 2.32.0
> 


More information about the U-Boot mailing list