summaryrefslogtreecommitdiff
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorLonglong Xia <xialonglong1@huawei.com>2023-02-10 09:54:42 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-02-10 11:26:36 +0100
commit31b4b6730fd4f5d503c9f23619c920ce7b794754 (patch)
tree0cdd9bf322ea2056db763a82c0efafcc9de32d31 /drivers/base/core.c
parentccfc901f01170721554963745f7bd94c15235c96 (diff)
driver core: add error handling for devtmpfs_create_node()
In some cases, devtmpfs_create_node() can return error value. So, make use of it. Signed-off-by: Longlong Xia <xialonglong1@huawei.com> Link: https://lore.kernel.org/r/20230210095444.4067307-2-xialonglong1@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index f9297c68214a..4fc6f27641bf 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3602,7 +3602,9 @@ int device_add(struct device *dev)
if (error)
goto SysEntryError;
- devtmpfs_create_node(dev);
+ error = devtmpfs_create_node(dev);
+ if (error)
+ goto DevtmpfsError;
}
/* Notify clients of device addition. This call must come
@@ -3658,6 +3660,8 @@ int device_add(struct device *dev)
done:
put_device(dev);
return error;
+ DevtmpfsError:
+ device_remove_sys_dev_entry(dev);
SysEntryError:
if (MAJOR(dev->devt))
device_remove_file(dev, &dev_attr_dev);