From: Frank Mori Hess Date: Thu, 2 May 2002 16:01:45 +0000 (+0000) Subject: fixing races X-Git-Tag: r0_7_65~71 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=48f35790d2af4303beca7e2805101f4308f83d74;p=comedi.git fixing races --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index 1bf594c5..50e1e968 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -478,7 +478,6 @@ static int do_bufinfo_ioctl(comedi_device *dev,void *arg) } } bi.buf_int_count = async->buf_int_count; - // XXX why why report the pointer values, they are useless to the user bi.buf_int_ptr = async->buf_int_ptr; bi.buf_user_count = async->buf_user_count; bi.buf_user_ptr = async->buf_user_ptr; @@ -1349,12 +1348,11 @@ static ssize_t comedi_write_v22(struct file *file,const char *buf,size_t nbytes, n=nbytes; - if( async->buf_user_ptr < async->buf_int_ptr) - m = async->buf_int_ptr - async->buf_user_ptr; - else + m = async->buf_int_ptr - async->buf_user_ptr; + if( m < 0 ) m = async->data_len - async->buf_user_count; - if(mf_flags&O_NONBLOCK){ @@ -1380,7 +1378,7 @@ static ssize_t comedi_write_v22(struct file *file,const char *buf,size_t nbytes, m=copy_from_user(async->data+async->buf_user_ptr,buf,n); if(m) retval=-EFAULT; n-=m; - + count+=n; nbytes-=n; async->buf_user_ptr+=n; @@ -1443,9 +1441,8 @@ static ssize_t comedi_read_v22(struct file * file,char *buf,size_t nbytes,loff_t n=nbytes; - if(async->buf_int_ptr >= async->buf_user_ptr) - m = async->buf_int_ptr - async->buf_user_ptr; - else + m = async->buf_int_ptr - async->buf_user_ptr; + if( m < 0 ) m = async->data_len - async->buf_user_ptr; #if 0