Re: Re: [PATCH] char:misc minor is overflowing

From: Shivnandan Kumar
Date: Mon Dec 14 2015 - 07:33:53 EST


Hi Alan,

Thanks for your reply.
Patch is not intended to increase DYNAMIC_MINORS from 64.
The error hadling in misc_register is not perfect.
Ideally, when misc minor number limit exceed then it should return -EBUSY instead of already
reserved minor number.
For example, in my case value of "i" in function misc_register is 62, so misc_minor becomes 1.
Which should not have happened, in this case it should return -EBUSY, as minor number 1 is reserved for PSMOUSE.
In error handling condition, it should consider already reserved minor numbers also.
This condition seems to be changed/modified.

"if (i >= DYNAMIC_MINORS) {
mutex_unlock(&misc_mtx);
return -EBUSY;
}"


Thanks,
Shivnandan
------- Original Message -------
Sender : One Thousand Gnomes<gnomes@xxxxxxxxxxxxxxxxxxx>
Date : Dec 09, 2015 22:35 (GMT+09:00)
Title : Re: [PATCH] char:misc minor is overflowing

On Wed, 09 Dec 2015 12:51:33 +0000 (GMT)
Nitin Gupta wrote:

> Hi,
>
> Is there any modification / improvement needed in this patch ?
>
> ------- Original Message -------
> Sender : Shivnandan Kumar Engineer/SRI-Noida-Advance Solutions - System 1 R&D Group/Samsung Electronics
> Date : Nov 20, 2015 15:35 (GMT+05:30)
> Title : [PATCH] char:misc minor is overflowing
>
> When a driver register as a misc driver and
> it tries to allocate minor number dynamically.
> Then there is a chance of minor number overflow.
> The problem is that 64(DYNAMIC_MINORS) is not enough

If you are allocating more than the odd minor number you shouldn't be
using misc devices in the first place but should be using
cdev_init/cdev_add/register_chrdev_region and friends.

So 64 really should never be "not enough". miscdevice is more historical
than useful and really goes back to the days long before all the region
allocators existed.

Alan