Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02aa2a37 authored by Kees Cook's avatar Kees Cook Committed by Linus Torvalds
Browse files

drivers: avoid format string in dev_set_name



Calling dev_set_name with a single paramter causes it to be handled as a
format string.  Many callers are passing potentially dynamic string
content, so use "%s" in those cases to avoid any potential accidents,
including wrappers like device_create*() and bdi_register().

Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 096a8aac
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
		ic->classdev.parent = get_device(dev);
		ic->classdev.class = cont->class;
		cont->class->dev_release = attribute_container_release;
		dev_set_name(&ic->classdev, dev_name(dev));
		dev_set_name(&ic->classdev, "%s", dev_name(dev));
		if (fn)
			fn(cont, dev, &ic->classdev);
		else
+1 −1
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
						GFP_KERNEL);
	devfreq->last_stat_updated = jiffies;

	dev_set_name(&devfreq->dev, dev_name(dev));
	dev_set_name(&devfreq->dev, "%s", dev_name(dev));
	err = device_register(&devfreq->dev);
	if (err) {
		put_device(&devfreq->dev);
+1 −1
Original line number Diff line number Diff line
@@ -602,7 +602,7 @@ int extcon_dev_register(struct extcon_dev *edev, struct device *dev)
	edev->dev->class = extcon_class;
	edev->dev->release = extcon_dev_release;

	dev_set_name(edev->dev, edev->name ? edev->name : dev_name(dev));
	dev_set_name(edev->dev, "%s", edev->name ? edev->name : dev_name(dev));

	if (edev->max_supported) {
		char buf[10];
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ static void hsi_new_client(struct hsi_port *port, struct hsi_board_info *info)
	cl->device.bus = &hsi_bus_type;
	cl->device.parent = &port->device;
	cl->device.release = hsi_client_release;
	dev_set_name(&cl->device, info->name);
	dev_set_name(&cl->device, "%s", info->name);
	cl->device.platform_data = info->platform_data;
	if (info->archdata)
		cl->device.archdata = *info->archdata;
+1 −1
Original line number Diff line number Diff line
@@ -1756,7 +1756,7 @@ static int ide_cd_probe(ide_drive_t *drive)

	info->dev.parent = &drive->gendev;
	info->dev.release = ide_cd_release;
	dev_set_name(&info->dev, dev_name(&drive->gendev));
	dev_set_name(&info->dev, "%s", dev_name(&drive->gendev));

	if (device_register(&info->dev))
		goto out_free_disk;
Loading