Re: [PATCH] rtc.c fix

From: Tigran Aivazian (tigran@aivazian.fsnet.co.uk)
Date: Fri Apr 28 2000 - 14:56:52 EST


On Fri, 28 Apr 2000, Cesar Eduardo Barros wrote:
> static int rtc_open(struct inode *inode, struct file *file)
> {
> - unsigned long flags;
> -
> - if(atomic_read(&rtc_status) & RTC_IS_OPEN)
> + /* If someday somebody decides to remove the kernel_lock on open and
> + * close and ioctl this is gonna get open to races */
> + if(rtc_status & RTC_IS_OPEN)
> return -EBUSY;
>
> MOD_INC_USE_COUNT;
>
> - atomic_set(&rtc_status, atomic_read(&rtc_status) | RTC_IS_OPEN);
> + rtc_status |= RTC_IS_OPEN;
>

why not use:

if (test_and_set_bit(RTC_IS_OPEN, &rtc_status))
      return -EBUSY;

(and also get rid of the comment claiming that it has a problem because
then it won't).

Regards,
Tigran

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:15 EST