Commit c8561c73 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'driver-core-7.1-rc5' of...

Merge tag 'driver-core-7.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core

Pull driver core fixes from Danilo Krummrich:

 - Remove the software node on platform device release(); without this,
   the software node remains registered after the device is gone and a
   subsequent platform_device_register_full() reusing the same node
   fails with -EBUSY

 - In sysfs_update_group(), do not remove a pre-existing directory when
   create_files() fails; the previous code would silently destroy a
   sysfs group that the caller did not create

 - Set fwnode->secondary to NULL in fwnode_init() to avoid dereferencing
   uninitialized memory (e.g. in dev_to_swnode()) when the firmware node
   is allocated on the stack or via a non-zeroing allocator

* tag 'driver-core-7.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core:
  device property: set fwnode->secondary to NULL in fwnode_init()
  sysfs: don't remove existing directory on update failure
  driver core: platform: remove software node on release()
parents 3f264650 215c90ee
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -606,6 +606,12 @@ static void platform_device_release(struct device *dev)
	kfree(pa);
}

static void platform_device_release_full(struct device *dev)
{
	device_remove_software_node(dev);
	platform_device_release(dev);
}

/**
 * platform_device_alloc - create a platform device
 * @name: base name of the device we're adding
@@ -848,7 +854,13 @@ struct platform_device *platform_device_register_full(const struct platform_devi
	int ret;
	struct platform_device *pdev;

	if (pdevinfo->swnode && pdevinfo->properties)
	/*
	 * Only one software node per device is allowed. Make sure we don't
	 * accept or create two.
	 */
	if ((pdevinfo->swnode && pdevinfo->properties) ||
	    (pdevinfo->swnode && is_software_node(pdevinfo->fwnode)) ||
	    (pdevinfo->properties && is_software_node(pdevinfo->fwnode)))
		return ERR_PTR(-EINVAL);

	pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
@@ -878,6 +890,8 @@ struct platform_device *platform_device_register_full(const struct platform_devi
		ret = device_add_software_node(&pdev->dev, pdevinfo->swnode);
		if (ret)
			goto err;

		pdev->dev.release = platform_device_release_full;
	} else if (pdevinfo->properties) {
		ret = device_create_managed_software_node(&pdev->dev,
							  pdevinfo->properties, NULL);
+1 −1
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ static int internal_create_group(struct kobject *kobj, int update,
	kernfs_get(kn);
	error = create_files(kn, kobj, uid, gid, grp, update);
	if (error) {
		if (grp->name)
		if (grp->name && !update)
			kernfs_remove(kn);
	}
	kernfs_put(kn);
+1 −0
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@ struct fwnode_operations {
static inline void fwnode_init(struct fwnode_handle *fwnode,
			       const struct fwnode_operations *ops)
{
	fwnode->secondary = NULL;
	fwnode->ops = ops;
	INIT_LIST_HEAD(&fwnode->consumers);
	INIT_LIST_HEAD(&fwnode->suppliers);