[lkml]   [2001]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Patch: Fix serial module use count (2.4.16 _and_ 2.5)
> close(-ENOMEM);

>What's that going to close? Hint: you _can't_ close
a descriptor that
>failed to open, since you don't have a descriptor to
close. You can
>only try to close an error code, but that's not going
to make it anywhere
>near the kernel driver level.

Let me make it clearer to you,

lets say I call rs_open() on /dev/ttyS0 and if it
fails then I should not call rs_close() after a failed

I hope this is clear now.

> The same thing applies to the code below. I think
that the open routine
> should instead set tty->driver_data to NULL upon

>Here's an example why that'd be real bad:

>1. process A opens /dev/ttyS0 as a normal device.
>This initialises
> tty->driver_data.
>2. process B tries to open /dev/cua0
>3. process B fails with -EBUSY since the normal
>device is open and active
> (see block_til_ready)
>4. since rs_open failed, we set tty->driver_data to
>be NULL (note that this
> is the same tty device pointer as (1) above.
>5. process A writes to /dev/ttyS0
>6. rs_write does the following:

> struct async_struct *info = (struct
async_struct *)tty->driver_data;

>7. Oops.

Lets see what happens with your approach

1. I call rs_open(), it fails, ref_count set to 1

2. I am sane enough not to call rs_close() on the
device which failed to open with rs_open the first
time, count is set to 1, driver never unloads.

I do not have access to block_til_ready currently.
But, I will see that function and revert with more

Balbir Singh.

Russell King ( The
developer of ARM Linux

Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:13    [W:0.169 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site