diff options
author | Peter Osterlund <petero2@telia.com> | 2005-05-20 16:59:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-05-20 18:48:16 -0400 |
commit | 46f4e1b7d5fa3ddf2486bf69716c404147e38ebf (patch) | |
tree | 8c632478e9e5c0b0a2f9601542e54d8f02250cb1 /drivers/block/pktcdvd.c | |
parent | 1c7878f024705594ac455e501ad51e475a400d5d (diff) |
[PATCH] packet driver permission checking fix
If you tried to open a packet device first in read-only mode and then a
second time in read-write mode, the second open succeeded even though the
device was not correctly set up for writing. If you then tried to write
data to the device, the writes would fail with I/O errors.
This patch prevents that problem by making the second open fail with
-EBUSY.
Signed-off-by: Peter Osterlund <petero2@telia.com>
Cc: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/block/pktcdvd.c')
-rw-r--r-- | drivers/block/pktcdvd.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index b9a6b7ad64f3..bc56770bcc90 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -2021,7 +2021,13 @@ static int pkt_open(struct inode *inode, struct file *file) | |||
2021 | BUG_ON(pd->refcnt < 0); | 2021 | BUG_ON(pd->refcnt < 0); |
2022 | 2022 | ||
2023 | pd->refcnt++; | 2023 | pd->refcnt++; |
2024 | if (pd->refcnt == 1) { | 2024 | if (pd->refcnt > 1) { |
2025 | if ((file->f_mode & FMODE_WRITE) && | ||
2026 | !test_bit(PACKET_WRITABLE, &pd->flags)) { | ||
2027 | ret = -EBUSY; | ||
2028 | goto out_dec; | ||
2029 | } | ||
2030 | } else { | ||
2025 | if (pkt_open_dev(pd, file->f_mode & FMODE_WRITE)) { | 2031 | if (pkt_open_dev(pd, file->f_mode & FMODE_WRITE)) { |
2026 | ret = -EIO; | 2032 | ret = -EIO; |
2027 | goto out_dec; | 2033 | goto out_dec; |