diff mbox series

[1/1] handlers: ubivol: fix missing device strlen check

Message ID 20240620084932.4759-2-sam.van.den.berge@gmail.com
State Accepted
Headers show
Series Fix failing A/B UBI volume updates | expand

Commit Message

Sam Van Den Berge June 20, 2024, 8:49 a.m. UTC
From: Sam Van Den Berge <sam.van.den.berge@gmail.com>

Commit "5604c225 handlers: ubivol: Allow specifying MTD device" breaks UBI A/B
volume updates with an atomic swap at the end of the update because 1 strlen
check is missing in ubi_volume_get_info.

This fixes the following error:

[ERROR] : SWUPDATE failed [0] ERROR :  does not exist
[ERROR] : SWUPDATE failed [0] ERROR : could not found UBI volume root_r
[ERROR] : SWUPDATE failed [0] ERROR : execute postinstall scripts failed
[ERROR] : SWUPDATE failed [1] Installation failed !

Signed-off-by: Sam Van Den Berge <sam.van.den.berge@gmail.com>
---
 handlers/ubivol_handler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dominique Martinet June 20, 2024, 9:08 a.m. UTC | #1
sam.van.den.berge@gmail.com wrote on Thu, Jun 20, 2024 at 10:49:32AM +0200:
> From: Sam Van Den Berge <sam.van.den.berge@gmail.com>
> 
> Commit "5604c225 handlers: ubivol: Allow specifying MTD device" breaks UBI A/B
> volume updates with an atomic swap at the end of the update because 1 strlen
> check is missing in ubi_volume_get_info.
> 
> This fixes the following error:
> 
> [ERROR] : SWUPDATE failed [0] ERROR :  does not exist
> [ERROR] : SWUPDATE failed [0] ERROR : could not found UBI volume root_r
> [ERROR] : SWUPDATE failed [0] ERROR : execute postinstall scripts failed
> [ERROR] : SWUPDATE failed [1] Installation failed !
> 
> Signed-off-by: Sam Van Den Berge <sam.van.den.berge@gmail.com>
> ---
>  handlers/ubivol_handler.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c
> index 9db6472e..0ad0321e 100644
> --- a/handlers/ubivol_handler.c
> +++ b/handlers/ubivol_handler.c
> @@ -506,7 +506,7 @@ static int ubi_volume_get_info(char *device, char *name, int *dev_num, int *vol_
>  {
>  	struct ubi_part *ubi_part;
>  
> -	if (device)
> +	if (strlen(device))

device comes from img->device which is part of img so cannot be NULL,
looks good to me.

(style wise I'd nitpick all these 'if (strlen(device))' checks in this
file could be 'if (device[0])' as we don't care about the length, but it
doesn't really matter for this kind of sizes)

Reviewed-by: Dominique Martinet <dominique.martinet@atmark-techno.com>

Thanks!
diff mbox series

Patch

diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c
index 9db6472e..0ad0321e 100644
--- a/handlers/ubivol_handler.c
+++ b/handlers/ubivol_handler.c
@@ -506,7 +506,7 @@  static int ubi_volume_get_info(char *device, char *name, int *dev_num, int *vol_
 {
 	struct ubi_part *ubi_part;
 
-	if (device)
+	if (strlen(device))
 		ubi_part = search_volume_local(device, name);
 	else
 		ubi_part = search_volume_global(name);