Skip to content

Commit

Permalink
char: add WARN_ON() in misc_deregister()
Browse files Browse the repository at this point in the history
misc_deregister() returns an error only when it attempts to unregister
the device that is not registered. This is the driver's bug.

Most of the drivers don't check the return value of misc_deregister().
(It is not bad thing because most of kernel *_unregister() API always
succeed and do not return value)

So it is better to indicate the error by WARN_ON() in misc_deregister().

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed Aug 10, 2010
1 parent 878ae12 commit b329bec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/char/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int misc_deregister(struct miscdevice *misc)
{
int i = DYNAMIC_MINORS - misc->minor - 1;

if (list_empty(&misc->list))
if (WARN_ON(list_empty(&misc->list)))
return -EINVAL;

mutex_lock(&misc_mtx);
Expand Down

0 comments on commit b329bec

Please sign in to comment.