|
@@ -3151,13 +3151,18 @@ struct class *tty_class;
|
|
static int tty_cdev_add(struct tty_driver *driver, dev_t dev,
|
|
static int tty_cdev_add(struct tty_driver *driver, dev_t dev,
|
|
unsigned int index, unsigned int count)
|
|
unsigned int index, unsigned int count)
|
|
{
|
|
{
|
|
|
|
+ int err;
|
|
|
|
+
|
|
/* init here, since reused cdevs cause crashes */
|
|
/* init here, since reused cdevs cause crashes */
|
|
driver->cdevs[index] = cdev_alloc();
|
|
driver->cdevs[index] = cdev_alloc();
|
|
if (!driver->cdevs[index])
|
|
if (!driver->cdevs[index])
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
- cdev_init(driver->cdevs[index], &tty_fops);
|
|
|
|
|
|
+ driver->cdevs[index]->ops = &tty_fops;
|
|
driver->cdevs[index]->owner = driver->owner;
|
|
driver->cdevs[index]->owner = driver->owner;
|
|
- return cdev_add(driver->cdevs[index], dev, count);
|
|
|
|
|
|
+ err = cdev_add(driver->cdevs[index], dev, count);
|
|
|
|
+ if (err)
|
|
|
|
+ kobject_put(&driver->cdevs[index]->kobj);
|
|
|
|
+ return err;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|