Re: [PATCH] The function register_chrdev_region() for count=0 returns a false success.This patch prevents that.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 25, 2008 at 11:55:25PM +0530, anubhav rakshit wrote:
> Signed-off-by: Anubhav Rakshit <anubhavrocks@xxxxxxxxx>
> ---
>  fs/char_dev.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/char_dev.c b/fs/char_dev.c
> index 038674a..f4c371a 100644
> --- a/fs/char_dev.c
> +++ b/fs/char_dev.c
> @@ -199,7 +199,10 @@ int register_chrdev_region(dev_t from, unsigned
> count, const char *name)
>  	struct char_device_struct *cd;
>  	dev_t to = from + count;
>  	dev_t n, next;
> -
> +	
> +	if(unlikely(count == 0))
> +		return -EINVAL;
> +	
>  	for (n = from; n < to; n = next) {
>  		next = MKDEV(MAJOR(n)+1, 0);
>  		if (next > to)

I'd say
a) unlikely in such rarely used function is useless
b)
	register_chrdev_region(from, 0, name);
	unregister_chrdev_region(from, 0);

  will unregister region sucessfully ;-)

c) this is problem of a caller -- don't!

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux