Commit 5e43754f authored by Yinghai Lu's avatar Yinghai Lu Committed by James Bottomley

[SCSI] ses: fix problems caused by empty SES provided name

We use the name provided by SES to name objects.  An empty name is
legal in SES but causes problems in our generic device hierarchy.  Fix
this by falling back to a number if the name is either NULL or empty.

Also fix a secondary bug spotted in that dev_set_name(dev, name) uses
a string format and so would go wrong if name contained a '%'.
Signed-off-by: default avatarYinghai Lu <yinghai@kernel.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent 9a1a69a1
...@@ -119,7 +119,7 @@ enclosure_register(struct device *dev, const char *name, int components, ...@@ -119,7 +119,7 @@ enclosure_register(struct device *dev, const char *name, int components,
edev->edev.class = &enclosure_class; edev->edev.class = &enclosure_class;
edev->edev.parent = get_device(dev); edev->edev.parent = get_device(dev);
edev->cb = cb; edev->cb = cb;
dev_set_name(&edev->edev, name); dev_set_name(&edev->edev, "%s", name);
err = device_register(&edev->edev); err = device_register(&edev->edev);
if (err) if (err)
goto err; goto err;
...@@ -255,8 +255,8 @@ enclosure_component_register(struct enclosure_device *edev, ...@@ -255,8 +255,8 @@ enclosure_component_register(struct enclosure_device *edev,
ecomp->number = number; ecomp->number = number;
cdev = &ecomp->cdev; cdev = &ecomp->cdev;
cdev->parent = get_device(&edev->edev); cdev->parent = get_device(&edev->edev);
if (name) if (name && name[0])
dev_set_name(cdev, name); dev_set_name(cdev, "%s", name);
else else
dev_set_name(cdev, "%u", number); dev_set_name(cdev, "%u", number);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment