From: Amit Shah Date: Fri, 12 Mar 2010 06:23:15 +0000 (+0530) Subject: hvc_console: Fix race between hvc_close and hvc_remove X-Git-Tag: v2.6.34-rc2~6^2~3 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e74d098c66543d0731de62eb747ccd5b636a6f4c;p=pandora-kernel.git hvc_console: Fix race between hvc_close and hvc_remove Alan pointed out a race in the code where hvc_remove is invoked. The recent virtio_console work is the first user of hvc_remove(). Alan describes it thus: The hvc_console assumes that a close and remove call can't occur at the same time. In addition tty_hangup(tty) is problematic as tty_hangup is asynchronous itself.... So this can happen hvc_close hvc_remove hung up ? - no lock tty = hp->tty unlock lock hp->tty = NULL unlock notify del kref_put the hvc struct close completes tty is destroyed tty_hangup dead tty tty->ops will be NULL NULL->... This patch adds some tty krefs and also converts to using tty_vhangup(). Reported-by: Alan Cox Signed-off-by: Amit Shah CC: Alan Cox CC: linuxppc-dev@ozlabs.org CC: Rusty Russell Signed-off-by: Greg Kroah-Hartman --- Reading git-diff-tree failed