Commit d7176726 authored by Stephen Hemminger's avatar Stephen Hemminger

[PATCH] propogate errors from misc_register to caller

The patch to check for / in class_device is not enough.
The misc_register function needs to check return value of the things it calls!
parent 117ace26
......@@ -212,6 +212,9 @@ static struct file_operations misc_fops = {
int misc_register(struct miscdevice * misc)
{
struct miscdevice *c;
struct class_device *class;
dev_t dev;
int err;
down(&misc_sem);
list_for_each_entry(c, &misc_list, list) {
......@@ -240,19 +243,30 @@ int misc_register(struct miscdevice * misc)
snprintf(misc->devfs_name, sizeof(misc->devfs_name),
"misc/%s", misc->name);
}
dev = MKDEV(MISC_MAJOR, misc->minor);
class_simple_device_add(misc_class, MKDEV(MISC_MAJOR, misc->minor),
misc->dev, misc->name);
devfs_mk_cdev(MKDEV(MISC_MAJOR, misc->minor),
S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, misc->devfs_name);
class = class_simple_device_add(misc_class, dev,
misc->dev, misc->name);
if (IS_ERR(class)) {
err = PTR_ERR(class);
goto out;
}
err = devfs_mk_cdev(dev, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP,
misc->devfs_name);
if (err) {
class_simple_device_remove(dev);
goto out;
}
/*
* Add it to the front, so that later devices can "override"
* earlier defaults
*/
list_add(&misc->list, &misc_list);
out:
up(&misc_sem);
return 0;
return err;
}
/**
......
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