mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails
@ 2023-03-14  8:58 Ahmad Fatoum
  2023-03-14  8:58 ` [PATCH master 2/2] commands: stat: fix UUID print Ahmad Fatoum
  2023-03-14  9:02 ` [PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-03-14  8:58 UTC (permalink / raw)
  To: barebox; +Cc: sha, Ahmad Fatoum

nvmem_partition_register should not be called with a NULL pointer
argument, yet this is what happened when a partition with a nvmem-cells
compatible conflicts with a partition parsed from an on-disk partition
table. Fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/partition.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index ed1114193062..40c47f554ad2 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -70,10 +70,10 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
 	if (IS_ERR(new)) {
 		pr_err("Adding partition %s failed: %pe\n", filename, new);
 		new = NULL;
+		goto out;
 	}
 
-	if (new)
-		new->device_node = node;
+	new->device_node = node;
 
 	if (IS_ENABLED(CONFIG_NVMEM) && of_device_is_compatible(node, "nvmem-cells")) {
 		struct nvmem_device *nvmem = nvmem_partition_register(new);
@@ -81,6 +81,7 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
 			dev_warn(cdev->dev, "nvmem registeration failed: %pe\n", nvmem);
 	}
 
+out:
 	free(filename);
 
 	return new;
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH master 2/2] commands: stat: fix UUID print
  2023-03-14  8:58 [PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails Ahmad Fatoum
@ 2023-03-14  8:58 ` Ahmad Fatoum
  2023-03-14  9:02 ` [PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-03-14  8:58 UTC (permalink / raw)
  To: barebox; +Cc: sha, Ahmad Fatoum

cdev->uuid is an already formatted string, not a binary UUID.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/fs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 4837c4b701bc..65e4c661b9ce 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -69,8 +69,6 @@ EXPORT_SYMBOL(mkmodestr);
 
 void cdev_print(const struct cdev *cdev)
 {
-	bool uuid_set;
-
 	if (cdev->dev || cdev->master || cdev->partname) {
 		printf("Origin: %s", dev_name(cdev->dev) ?: "None");
 		if (cdev->master)
@@ -98,14 +96,13 @@ void cdev_print(const struct cdev *cdev)
 	}
 	printf("\n");
 
-	uuid_set = memchr_inv(cdev->uuid, 0x00 ,sizeof(cdev->uuid));
-	if (cdev->filetype || cdev->dos_partition_type || uuid_set) {
+	if (cdev->filetype || cdev->dos_partition_type || *cdev->uuid) {
 		if (cdev->filetype)
 			printf("Filetype: %s\t", file_type_to_string(cdev->filetype));
 		if (cdev->dos_partition_type)
 			printf("DOS parttype: 0x%02x\t", cdev->dos_partition_type);
-		if (uuid_set)
-			printf("UUID: %pUl", cdev->uuid);
+		if (*cdev->uuid)
+			printf("UUID: %s", cdev->uuid);
 		printf("\n");
 	}
 }
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails
  2023-03-14  8:58 [PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails Ahmad Fatoum
  2023-03-14  8:58 ` [PATCH master 2/2] commands: stat: fix UUID print Ahmad Fatoum
@ 2023-03-14  9:02 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-03-14  9:02 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Tue, Mar 14, 2023 at 09:58:04AM +0100, Ahmad Fatoum wrote:
> nvmem_partition_register should not be called with a NULL pointer
> argument, yet this is what happened when a partition with a nvmem-cells
> compatible conflicts with a partition parsed from an on-disk partition
> table. Fix this.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/of/partition.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/of/partition.c b/drivers/of/partition.c
> index ed1114193062..40c47f554ad2 100644
> --- a/drivers/of/partition.c
> +++ b/drivers/of/partition.c
> @@ -70,10 +70,10 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
>  	if (IS_ERR(new)) {
>  		pr_err("Adding partition %s failed: %pe\n", filename, new);
>  		new = NULL;
> +		goto out;
>  	}
>  
> -	if (new)
> -		new->device_node = node;
> +	new->device_node = node;
>  
>  	if (IS_ENABLED(CONFIG_NVMEM) && of_device_is_compatible(node, "nvmem-cells")) {
>  		struct nvmem_device *nvmem = nvmem_partition_register(new);
> @@ -81,6 +81,7 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
>  			dev_warn(cdev->dev, "nvmem registeration failed: %pe\n", nvmem);
>  	}
>  
> +out:
>  	free(filename);
>  
>  	return new;
> -- 
> 2.30.2
> 
> 

-- 
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 |




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-14 13:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14  8:58 [PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails Ahmad Fatoum
2023-03-14  8:58 ` [PATCH master 2/2] commands: stat: fix UUID print Ahmad Fatoum
2023-03-14  9:02 ` [PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox