Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100274
b: refs/heads/master
c: ea2959a
h: refs/heads/master
v: v3
  • Loading branch information
Jonathan Corbet committed Jun 20, 2008
1 parent 58d519f commit 5c5e02f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 579174a55f491edeaccb8f5d3dc7ad69a17f5423
refs/heads/master: ea2959a2972410f15155a015df74ce77ac79f8b8
22 changes: 16 additions & 6 deletions trunk/drivers/block/paride/pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
#include <linux/pg.h>
#include <linux/device.h>
#include <linux/sched.h> /* current, TASK_* */
#include <linux/smp_lock.h>
#include <linux/jiffies.h>

#include <asm/uaccess.h>
Expand Down Expand Up @@ -515,12 +516,18 @@ static int pg_open(struct inode *inode, struct file *file)
{
int unit = iminor(inode) & 0x7f;
struct pg *dev = &devices[unit];
int ret = 0;

if ((unit >= PG_UNITS) || (!dev->present))
return -ENODEV;
lock_kernel();
if ((unit >= PG_UNITS) || (!dev->present)) {
ret = -ENODEV;
goto out;
}

if (test_and_set_bit(0, &dev->access))
return -EBUSY;
if (test_and_set_bit(0, &dev->access)) {
ret = -EBUSY;
goto out;
}

if (dev->busy) {
pg_reset(dev);
Expand All @@ -533,12 +540,15 @@ static int pg_open(struct inode *inode, struct file *file)
if (dev->bufptr == NULL) {
clear_bit(0, &dev->access);
printk("%s: buffer allocation failed\n", dev->name);
return -ENOMEM;
ret = -ENOMEM;
goto out;
}

file->private_data = dev;

return 0;
out:
unlock_kernel();
return ret;
}

static int pg_release(struct inode *inode, struct file *file)
Expand Down
8 changes: 7 additions & 1 deletion trunk/drivers/block/paride/pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ static int (*drives[4])[6] = {&drive0, &drive1, &drive2, &drive3};
#include <linux/mtio.h>
#include <linux/device.h>
#include <linux/sched.h> /* current, TASK_*, schedule_timeout() */
#include <linux/smp_lock.h>

#include <asm/uaccess.h>

Expand Down Expand Up @@ -650,8 +651,11 @@ static int pt_open(struct inode *inode, struct file *file)
struct pt_unit *tape = pt + unit;
int err;

if (unit >= PT_UNITS || (!tape->present))
lock_kernel();
if (unit >= PT_UNITS || (!tape->present)) {
unlock_kernel();
return -ENODEV;
}

err = -EBUSY;
if (!atomic_dec_and_test(&tape->available))
Expand All @@ -678,10 +682,12 @@ static int pt_open(struct inode *inode, struct file *file)
}

file->private_data = tape;
unlock_kernel();
return 0;

out:
atomic_inc(&tape->available);
unlock_kernel();
return err;
}

Expand Down

0 comments on commit 5c5e02f

Please sign in to comment.