[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20220921004406.2560-1-liubo03@inspur.com>
Date: Tue, 20 Sep 2022 20:44:06 -0400
From: Bo Liu <liubo03@...pur.com>
To: <dan.j.williams@...el.com>, <vishal.l.verma@...el.com>,
<dave.jiang@...el.com>
CC: <nvdimm@...ts.linux.dev>, <linux-kernel@...r.kernel.org>,
Bo Liu <liubo03@...pur.com>
Subject: [PATCH v2 1/1] dax: Check dev_set_name() return value
It's possible that dev_set_name() returns -ENOMEM, catch and handle this.
Signed-off-by: Bo Liu <liubo03@...pur.com>
---
Changes from v1:
-use put_device() replace free()
drivers/dax/bus.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index 1dad813ee4a6..2e736c7df46c 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -765,7 +765,12 @@ static int devm_register_dax_mapping(struct dev_dax *dev_dax, int range_id)
device_initialize(dev);
dev->parent = &dev_dax->dev;
dev->type = &dax_mapping_type;
- dev_set_name(dev, "mapping%d", mapping->id);
+ rc = dev_set_name(dev, "mapping%d", mapping->id);
+ if (rc) {
+ put_device(dev);
+ return rc;
+ }
+
rc = device_add(dev);
if (rc) {
put_device(dev);
@@ -1334,7 +1339,9 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
dev_dax->region = dax_region;
dev = &dev_dax->dev;
device_initialize(dev);
- dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id);
+ rc = dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id);
+ if (rc)
+ goto err_range;
rc = alloc_dev_dax_range(dev_dax, dax_region->res.start, data->size);
if (rc)
--
2.27.0
Powered by blists - more mailing lists