Commit 6d9eac34104654aa129e365b8d48bbb8c957f186

Authored by Andrew Morton
Committed by Linus Torvalds
1 parent 829d5f68ec

[PATCH] capi: register_chrdev() fix

If the user specified `major=0' (odd thing to do), capi.c will use dynamic
allocation.  We need to pick up that major for subsequent unregister_chrdev().

Acked-by: Karsten Keil <kkeil@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 5 additions and 3 deletions Side-by-side Diff

drivers/isdn/capi/capi.c
... ... @@ -1485,6 +1485,7 @@
1485 1485 {
1486 1486 char *p;
1487 1487 char *compileinfo;
  1488 + int major_ret;
1488 1489  
1489 1490 if ((p = strchr(revision, ':')) != 0 && p[1]) {
1490 1491 strlcpy(rev, p + 2, sizeof(rev));
1491 1492  
1492 1493  
... ... @@ -1493,11 +1494,12 @@
1493 1494 } else
1494 1495 strcpy(rev, "1.0");
1495 1496  
1496   - if (register_chrdev(capi_major, "capi20", &capi_fops)) {
  1497 + major_ret = register_chrdev(capi_major, "capi20", &capi_fops);
  1498 + if (major_ret < 0) {
1497 1499 printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
1498   - return -EIO;
  1500 + return major_ret;
1499 1501 }
1500   -
  1502 + capi_major = major_ret;
1501 1503 capi_class = class_create(THIS_MODULE, "capi");
1502 1504 if (IS_ERR(capi_class)) {
1503 1505 unregister_chrdev(capi_major, "capi20");