Fix the crash reported in the "another critical bug ?" thread, which turned out to be caused by a stale input_dev pointer. The patch applies to current -git and latest -stable.