Skip to content

Commit 8637980

Browse files
Andrew MortonLinus Torvalds
authored andcommitted
[PATCH] paride: register_chrdev fix
If the user specified `major=0' (odd thing to do), pg.c will use dynamic allocation. We need to pick up that major for subsequent unregister_chrdev(). Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent a687fb1 commit 8637980

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • drivers/block/paride

‎drivers/block/paride/pg.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ static ssize_t pg_read(struct file *filp, char __user *buf, size_t count, loff_t
643643

644644
static int __init pg_init(void)
645645
{
646-
int unit, err = 0;
646+
int unit;
647+
int err;
647648

648649
if (disable){
649650
err = -1;
@@ -657,16 +658,17 @@ static int __init pg_init(void)
657658
goto out;
658659
}
659660

660-
if (register_chrdev(major, name, &pg_fops)) {
661+
err = register_chrdev(major, name, &pg_fops);
662+
if (err < 0) {
661663
printk("pg_init: unable to get major number %d\n", major);
662664
for (unit = 0; unit < PG_UNITS; unit++) {
663665
struct pg *dev = &devices[unit];
664666
if (dev->present)
665667
pi_release(dev->pi);
666668
}
667-
err = -1;
668669
goto out;
669670
}
671+
major = err; /* In case the user specified `major=0' (dynamic) */
670672
pg_class = class_create(THIS_MODULE, "pg");
671673
if (IS_ERR(pg_class)) {
672674
err = PTR_ERR(pg_class);

0 commit comments

Comments
 (0)