mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: sha@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 1/2] of: partition: skip NVMEM partition setup partition parsing fails
Date: Tue, 14 Mar 2023 09:58:04 +0100	[thread overview]
Message-ID: <20230314085805.1860986-1-a.fatoum@pengutronix.de> (raw)

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





             reply	other threads:[~2023-03-14 13:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14  8:58 Ahmad Fatoum [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230314085805.1860986-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=sha@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox