Re: [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl

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

 



On Thu, Jan 10, 2008 at 11:44:20AM +0530, Nikanth Karthikesan wrote:
> -static int pt_ioctl(struct inode *inode, struct file *file,
> -	 unsigned int cmd, unsigned long arg)
> +static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long
> arg)

this looks line-wrapper by your mailer.

> -		if (copy_from_user(&mtop, p, sizeof(struct mtop)))
> +		if (copy_from_user(&mtop, p, sizeof(struct mtop))) {
> +			unlock_kernel();
>  			return -EFAULT;
> +		}
> 
>  		switch (mtop.mt_op) {
> 
>  		case MTREW:
>  			pt_rewind(tape);
> +			unlock_kernel();

It's generally considered good style to only have as few as possible
return values.  And this is especially important when returning from
a section that's under a lock.  So in this case it would be much better
if you changes this function to have a local 'int error' variable
and then just do

	error = -EFOO;
	goto out_unlock;

wherever you have an early return with the end of the function looking
like


out_unlock:
	unlock_kernel();
	return error;
-
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