OSDN Git Service

net_sched: fix an OOB access in cls_tcindex
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / fs / char_dev.c
index 24b1425..f1f3bb8 100644 (file)
@@ -130,6 +130,12 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
                        ret = -EBUSY;
                        goto out;
                }
+
+               if (new_min < old_min && new_max > old_max) {
+                       ret = -EBUSY;
+                       goto out;
+               }
+
        }
 
        cd->next = *cp;
@@ -326,7 +332,7 @@ static struct kobject *cdev_get(struct cdev *p)
 
        if (owner && !try_module_get(owner))
                return NULL;
-       kobj = kobject_get(&p->kobj);
+       kobj = kobject_get_unless_zero(&p->kobj);
        if (!kobj)
                module_put(owner);
        return kobj;