Skip to content

Commit

Permalink
staging/crystalhd: unregister chardev when class_create fails in chd_…
Browse files Browse the repository at this point in the history
…dec_init_chdev

we missed a unregiser_chrdev if the class_create and subsequent function calls / checks fail

Signed-off-by: Devendra Naga <develkernel412222@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Devendra Naga authored and Greg Kroah-Hartman committed Aug 14, 2012
1 parent 3b2f1fb commit 675fe09
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/staging/crystalhd/crystalhd_lnx.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ static int __devinit chd_dec_init_chdev(struct crystalhd_adp *adp)
if (IS_ERR(crystalhd_class)) {
rc = PTR_ERR(crystalhd_class);
BCMLOG_ERR("failed to create class\n");
goto fail;
goto class_create_fail;
}

dev = device_create(crystalhd_class, NULL, MKDEV(adp->chd_dec_major, 0),
Expand Down Expand Up @@ -412,6 +412,8 @@ static int __devinit chd_dec_init_chdev(struct crystalhd_adp *adp)
device_destroy(crystalhd_class, MKDEV(adp->chd_dec_major, 0));
device_create_fail:
class_destroy(crystalhd_class);
class_create_fail:
unregister_chrdev(adp->chd_dec_major, CRYSTALHD_API_NAME);
fail:
return rc;
}
Expand Down

0 comments on commit 675fe09

Please sign in to comment.