1. 25 Apr, 2013 40 commits
    • Felix Fietkau's avatar
      ath9k_htc: accept 1.x firmware newer than 1.3 · add02e68
      Felix Fietkau authored
      commit 319e7bd9 upstream.
      
      Since the firmware has been open sourced, the minor version has been
      bumped to 1.4 and the API/ABI will stay compatible across further 1.x
      releases.
      Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      add02e68
    • Russell King's avatar
      ARM: Do 15e0d9e3 (ARM: pm: let platforms select cpu_suspend support) properly · 5e034d8d
      Russell King authored
      commit b6c7aabd upstream.
      
      Let's do the changes properly and fix the same problem everywhere, not
      just for one case.
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      [bwh: Backported to 3.2: mohawk doesn't support suspend at all]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5e034d8d
    • Suleiman Souhlal's avatar
      vfs: Revert spurious fix to spinning prevention in prune_icache_sb · 5ef143d9
      Suleiman Souhlal authored
      commit 5b55d708 upstream.
      
      Revert commit 62a3ddef ("vfs: fix spinning prevention in prune_icache_sb").
      
      This commit doesn't look right: since we are looking at the tail of the
      list (sb->s_inode_lru.prev) if we want to skip an inode, we should put
      it back at the head of the list instead of the tail, otherwise we will
      keep spinning on it.
      
      Discovered when investigating why prune_icache_sb came top in perf
      reports of a swapping load.
      Signed-off-by: default avatarSuleiman Souhlal <suleiman@google.com>
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5ef143d9
    • Linus Torvalds's avatar
      kobject: fix kset_find_obj() race with concurrent last kobject_put() · c6680a13
      Linus Torvalds authored
      commit a49b7e82 upstream.
      
      Anatol Pomozov identified a race condition that hits module unloading
      and re-loading.  To quote Anatol:
      
       "This is a race codition that exists between kset_find_obj() and
        kobject_put().  kset_find_obj() might return kobject that has refcount
        equal to 0 if this kobject is freeing by kobject_put() in other
        thread.
      
        Here is timeline for the crash in case if kset_find_obj() searches for
        an object tht nobody holds and other thread is doing kobject_put() on
        the same kobject:
      
          THREAD A (calls kset_find_obj())     THREAD B (calls kobject_put())
          splin_lock()
                                               atomic_dec_return(kobj->kref), counter gets zero here
                                               ... starts kobject cleanup ....
                                               spin_lock() // WAIT thread A in kobj_kset_leave()
          iterate over kset->list
          atomic_inc(kobj->kref) (counter becomes 1)
          spin_unlock()
                                               spin_lock() // taken
                                               // it does not know that thread A increased counter so it
                                               remove obj from list
                                               spin_unlock()
                                               vfree(module) // frees module object with containing kobj
      
          // kobj points to freed memory area!!
          kobject_put(kobj) // OOPS!!!!
      
        The race above happens because module.c tries to use kset_find_obj()
        when somebody unloads module.  The module.c code was introduced in
        commit 6494a93d"
      
      Anatol supplied a patch specific for module.c that worked around the
      problem by simply not using kset_find_obj() at all, but rather than make
      a local band-aid, this just fixes kset_find_obj() to be thread-safe
      using the proper model of refusing the get a new reference if the
      refcount has already dropped to zero.
      
      See examples of this proper refcount handling not only in the kref
      documentation, but in various other equivalent uses of this pattern by
      grepping for atomic_inc_not_zero().
      
      [ Side note: the module race does indicate that module loading and
        unloading is not properly serialized wrt sysfs information using the
        module mutex.  That may require further thought, but this is the
        correct fix at the kobject layer regardless. ]
      Reported-analyzed-and-tested-by: default avatarAnatol Pomozov <anatol.pomozov@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      c6680a13
    • Thomas Hellstrom's avatar
      kref: Implement kref_get_unless_zero v3 · 3fa8ee5f
      Thomas Hellstrom authored
      commit 4b20db3d upstream.
      
      This function is intended to simplify locking around refcounting for
      objects that can be looked up from a lookup structure, and which are
      removed from that lookup structure in the object destructor.
      Operations on such objects require at least a read lock around
      lookup + kref_get, and a write lock around kref_put + remove from lookup
      structure. Furthermore, RCU implementations become extremely tricky.
      With a lookup followed by a kref_get_unless_zero *with return value check*
      locking in the kref_put path can be deferred to the actual removal from
      the lookup structure and RCU lookups become trivial.
      
      v2: Formatting fixes.
      v3: Invert the return value.
      Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      [bwh: Backported to 3.2:
       - Adjust context
       - Add #include <linux/atomic.h>]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3fa8ee5f
    • Josef Bacik's avatar
      Btrfs: make sure nbytes are right after log replay · 595b57bb
      Josef Bacik authored
      commit 4bc4bee4 upstream.
      
      While trying to track down a tree log replay bug I noticed that fsck was always
      complaining about nbytes not being right for our fsynced file.  That is because
      the new fsync stuff doesn't wait for ordered extents to complete, so the inodes
      nbytes are not necessarily updated properly when we log it.  So to fix this we
      need to set nbytes to whatever it is on the inode that is on disk, so when we
      replay the extents we can just add the bytes that are being added as we replay
      the extent.  This makes it work for the case that we have the wrong nbytes or
      the case that we logged everything and nbytes is actually correct.  With this
      I'm no longer getting nbytes errors out of btrfsck.
      Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      595b57bb
    • Namhyung Kim's avatar
      tracing: Fix possible NULL pointer dereferences · ee3c9aab
      Namhyung Kim authored
      commit 6a76f8c0 upstream.
      
      Currently set_ftrace_pid and set_graph_function files use seq_lseek
      for their fops.  However seq_open() is called only for FMODE_READ in
      the fops->open() so that if an user tries to seek one of those file
      when she open it for writing, it sees NULL seq_file and then panic.
      
      It can be easily reproduced with following command:
      
        $ cd /sys/kernel/debug/tracing
        $ echo 1234 | sudo tee -a set_ftrace_pid
      
      In this example, GNU coreutils' tee opens the file with fopen(, "a")
      and then the fopen() internally calls lseek().
      
      Link: http://lkml.kernel.org/r/1365663302-2170-1-git-send-email-namhyung@kernel.org
      
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      [bwh: Backported to 3.2: ftrace_regex_lseek() is static]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      ee3c9aab
    • Nicholas Bellinger's avatar
      target: Fix incorrect fallthrough of ALUA Standby/Offline/Transition CDBs · 2ee3a5e3
      Nicholas Bellinger authored
      commit 30f359a6 upstream.
      
      This patch fixes a bug where a handful of informational / control CDBs
      that should be allowed during ALUA access state Standby/Offline/Transition
      where incorrectly returning CHECK_CONDITION + ASCQ_04H_ALUA_TG_PT_*.
      
      This includes INQUIRY + REPORT_LUNS, which would end up preventing LUN
      registration when LUN scanning occured during these ALUA access states.
      
      Cc: Hannes Reinecke <hare@suse.de>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2ee3a5e3
    • Nicholas Bellinger's avatar
      target: Fix MAINTENANCE_IN service action CDB checks to use lower 5 bits · d801775a
      Nicholas Bellinger authored
      commit ba539743 upstream.
      
      This patch fixes the MAINTENANCE_IN service action type checks to only
      look at the proper lower 5 bits of cdb byte 1.  This addresses the case
      where MI_REPORT_TARGET_PGS w/ extended header using the upper three bits of
      cdb byte 1 was not processed correctly in transport_generic_cmd_sequencer,
      as well as the three cases for standby, unavailable, and transition ALUA
      primary access state checks.
      
      Also add MAINTENANCE_IN to the excluded list in transport_generic_prepare_cdb()
      to prevent the PARAMETER DATA FORMAT bits from being cleared.
      
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Rob Evers <revers@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Roland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      d801775a
    • Boris Ostrovsky's avatar
      x86, mm: Patch out arch_flush_lazy_mmu_mode() when running on bare metal · 04de139a
      Boris Ostrovsky authored
      commit 511ba86e upstream.
      
      Invoking arch_flush_lazy_mmu_mode() results in calls to
      preempt_enable()/disable() which may have performance impact.
      
      Since lazy MMU is not used on bare metal we can patch away
      arch_flush_lazy_mmu_mode() so that it is never called in such
      environment.
      
      [ hpa: the previous patch "Fix vmalloc_fault oops during lazy MMU
        updates" may cause a minor performance regression on
        bare metal.  This patch resolves that performance regression.  It is
        somewhat unclear to me if this is a good -stable candidate. ]
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Link: http://lkml.kernel.org/r/1364045796-10720-2-git-send-email-konrad.wilk@oracle.comTested-by: default avatarJosh Boyer <jwboyer@redhat.com>
      Tested-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      04de139a
    • Samu Kallio's avatar
      x86, mm, paravirt: Fix vmalloc_fault oops during lazy MMU updates · 5bb757c0
      Samu Kallio authored
      commit 1160c277 upstream.
      
      In paravirtualized x86_64 kernels, vmalloc_fault may cause an oops
      when lazy MMU updates are enabled, because set_pgd effects are being
      deferred.
      
      One instance of this problem is during process mm cleanup with memory
      cgroups enabled. The chain of events is as follows:
      
      - zap_pte_range enables lazy MMU updates
      - zap_pte_range eventually calls mem_cgroup_charge_statistics,
        which accesses the vmalloc'd mem_cgroup per-cpu stat area
      - vmalloc_fault is triggered which tries to sync the corresponding
        PGD entry with set_pgd, but the update is deferred
      - vmalloc_fault oopses due to a mismatch in the PUD entries
      
      The OOPs usually looks as so:
      
      ------------[ cut here ]------------
      kernel BUG at arch/x86/mm/fault.c:396!
      invalid opcode: 0000 [#1] SMP
      .. snip ..
      CPU 1
      Pid: 10866, comm: httpd Not tainted 3.6.10-4.fc18.x86_64 #1
      RIP: e030:[<ffffffff816271bf>]  [<ffffffff816271bf>] vmalloc_fault+0x11f/0x208
      .. snip ..
      Call Trace:
       [<ffffffff81627759>] do_page_fault+0x399/0x4b0
       [<ffffffff81004f4c>] ? xen_mc_extend_args+0xec/0x110
       [<ffffffff81624065>] page_fault+0x25/0x30
       [<ffffffff81184d03>] ? mem_cgroup_charge_statistics.isra.13+0x13/0x50
       [<ffffffff81186f78>] __mem_cgroup_uncharge_common+0xd8/0x350
       [<ffffffff8118aac7>] mem_cgroup_uncharge_page+0x57/0x60
       [<ffffffff8115fbc0>] page_remove_rmap+0xe0/0x150
       [<ffffffff8115311a>] ? vm_normal_page+0x1a/0x80
       [<ffffffff81153e61>] unmap_single_vma+0x531/0x870
       [<ffffffff81154962>] unmap_vmas+0x52/0xa0
       [<ffffffff81007442>] ? pte_mfn_to_pfn+0x72/0x100
       [<ffffffff8115c8f8>] exit_mmap+0x98/0x170
       [<ffffffff810050d9>] ? __raw_callee_save_xen_pmd_val+0x11/0x1e
       [<ffffffff81059ce3>] mmput+0x83/0xf0
       [<ffffffff810624c4>] exit_mm+0x104/0x130
       [<ffffffff8106264a>] do_exit+0x15a/0x8c0
       [<ffffffff810630ff>] do_group_exit+0x3f/0xa0
       [<ffffffff81063177>] sys_exit_group+0x17/0x20
       [<ffffffff8162bae9>] system_call_fastpath+0x16/0x1b
      
      Calling arch_flush_lazy_mmu_mode immediately after set_pgd makes the
      changes visible to the consistency checks.
      
      RedHat-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=914737Tested-by: default avatarJosh Boyer <jwboyer@redhat.com>
      Reported-and-Tested-by: default avatarKrishna Raman <kraman@redhat.com>
      Signed-off-by: default avatarSamu Kallio <samu.kallio@aberdeencloud.com>
      Link: http://lkml.kernel.org/r/1364045796-10720-1-git-send-email-konrad.wilk@oracle.comTested-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5bb757c0
    • Namhyung Kim's avatar
      tracing: Fix double free when function profile init failed · fb8384c3
      Namhyung Kim authored
      commit 83e03b3f upstream.
      
      On the failure path, stat->start and stat->pages will refer same page.
      So it'll attempt to free the same page again and get kernel panic.
      
      Link: http://lkml.kernel.org/r/1364820385-32027-1-git-send-email-namhyung@kernel.org
      
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      fb8384c3
    • Linus Torvalds's avatar
      spinlocks and preemption points need to be at least compiler barriers · 9dc0052f
      Linus Torvalds authored
      commit 386afc91 upstream.
      
      In UP and non-preempt respectively, the spinlocks and preemption
      disable/enable points are stubbed out entirely, because there is no
      regular code that can ever hit the kind of concurrency they are meant to
      protect against.
      
      However, while there is no regular code that can cause scheduling, we
      _do_ end up having some exceptional (literally!) code that can do so,
      and that we need to make sure does not ever get moved into the critical
      region by the compiler.
      
      In particular, get_user() and put_user() is generally implemented as
      inline asm statements (even if the inline asm may then make a call
      instruction to call out-of-line), and can obviously cause a page fault
      and IO as a result.  If that inline asm has been scheduled into the
      middle of a preemption-safe (or spinlock-protected) code region, we
      obviously lose.
      
      Now, admittedly this is *very* unlikely to actually ever happen, and
      we've not seen examples of actual bugs related to this.  But partly
      exactly because it's so hard to trigger and the resulting bug is so
      subtle, we should be extra careful to get this right.
      
      So make sure that even when preemption is disabled, and we don't have to
      generate any actual *code* to explicitly tell the system that we are in
      a preemption-disabled region, we need to at least tell the compiler not
      to move things around the critical region.
      
      This patch grew out of the same discussion that caused commits
      79e5f05e ("ARC: Add implicit compiler barrier to raw_local_irq*
      functions") and 3e2e0d2c ("tile: comment assumption about
      __insn_mtspr for <asm/irqflags.h>") to come about.
      
      Note for stable: use discretion when/if applying this.  As mentioned,
      this bug may never have actually bitten anybody, and gcc may never have
      done the required code motion for it to possibly ever trigger in
      practice.
      
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      [bwh: Backported to 3.2: drop sched_preempt_enable_no_resched()]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      9dc0052f
    • Alban Bedel's avatar
      ASoC: wm8903: Fix the bypass to HP/LINEOUT when no DAC or ADC is running · 6248d3d8
      Alban Bedel authored
      commit f1ca493b upstream.
      
      The Charge Pump needs the DSP clock to work properly, without it the
      bypass to HP/LINEOUT is not working properly. This requirement is not
      mentioned in the datasheet but has been confirmed by Mark Brown from
      Wolfson.
      Signed-off-by: default avatarAlban Bedel <alban.bedel@avionic-design.de>
      Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      6248d3d8
    • Wei Yongjun's avatar
      can: gw: use kmem_cache_free() instead of kfree() · d9d7d36d
      Wei Yongjun authored
      commit 3480a212 upstream.
      
      Memory allocated by kmem_cache_alloc() should be freed using
      kmem_cache_free(), not kfree().
      Signed-off-by: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
      Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      d9d7d36d
    • Huacai Chen's avatar
      PM / reboot: call syscore_shutdown() after disable_nonboot_cpus() · 903bd59a
      Huacai Chen authored
      commit 6f389a8f upstream.
      
      As commit 40dc166c (PM / Core: Introduce struct syscore_ops for core
      subsystems PM) say, syscore_ops operations should be carried with one
      CPU on-line and interrupts disabled. However, after commit f96972f2
      (kernel/sys.c: call disable_nonboot_cpus() in kernel_restart()),
      syscore_shutdown() is called before disable_nonboot_cpus(), so break
      the rules. We have a MIPS machine with a 8259A PIC, and there is an
      external timer (HPET) linked at 8259A. Since 8259A has been shutdown
      too early (by syscore_shutdown()), disable_nonboot_cpus() runs without
      timer interrupt, so it hangs and reboot fails. This patch call
      syscore_shutdown() a little later (after disable_nonboot_cpus()) to
      avoid reboot failure, this is the same way as poweroff does.
      
      For consistency, add disable_nonboot_cpus() to kernel_halt().
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      903bd59a
    • Jan Kiszka's avatar
      ftrace: Consistently restore trace function on sysctl enabling · b7e45b96
      Jan Kiszka authored
      commit 5000c418 upstream.
      
      If we reenable ftrace via syctl, we currently set ftrace_trace_function
      based on the previous simplistic algorithm. This is inconsistent with
      what update_ftrace_function does. So better call that helper instead.
      
      Link: http://lkml.kernel.org/r/5151D26F.1070702@siemens.comSigned-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      b7e45b96
    • Thomas Gleixner's avatar
      sched_clock: Prevent 64bit inatomicity on 32bit systems · 4dfc47d2
      Thomas Gleixner authored
      commit a1cbcaa9 upstream.
      
      The sched_clock_remote() implementation has the following inatomicity
      problem on 32bit systems when accessing the remote scd->clock, which
      is a 64bit value.
      
      CPU0			CPU1
      
      sched_clock_local()	sched_clock_remote(CPU0)
      ...
      			remote_clock = scd[CPU0]->clock
      			    read_low32bit(scd[CPU0]->clock)
      cmpxchg64(scd->clock,...)
      			    read_high32bit(scd[CPU0]->clock)
      
      While the update of scd->clock is using an atomic64 mechanism, the
      readout on the remote cpu is not, which can cause completely bogus
      readouts.
      
      It is a quite rare problem, because it requires the update to hit the
      narrow race window between the low/high readout and the update must go
      across the 32bit boundary.
      
      The resulting misbehaviour is, that CPU1 will see the sched_clock on
      CPU1 ~4 seconds ahead of it's own and update CPU1s sched_clock value
      to this bogus timestamp. This stays that way due to the clamping
      implementation for about 4 seconds until the synchronization with
      CLOCK_MONOTONIC undoes the problem.
      
      The issue is hard to observe, because it might only result in a less
      accurate SCHED_OTHER timeslicing behaviour. To create observable
      damage on realtime scheduling classes, it is necessary that the bogus
      update of CPU1 sched_clock happens in the context of an realtime
      thread, which then gets charged 4 seconds of RT runtime, which results
      in the RT throttler mechanism to trigger and prevent scheduling of RT
      tasks for a little less than 4 seconds. So this is quite unlikely as
      well.
      
      The issue was quite hard to decode as the reproduction time is between
      2 days and 3 weeks and intrusive tracing makes it less likely, but the
      following trace recorded with trace_clock=global, which uses
      sched_clock_local(), gave the final hint:
      
        <idle>-0   0d..30 400269.477150: hrtimer_cancel: hrtimer=0xf7061e80
        <idle>-0   0d..30 400269.477151: hrtimer_start:  hrtimer=0xf7061e80 ...
      irq/20-S-587 1d..32 400273.772118: sched_wakeup:   comm= ... target_cpu=0
        <idle>-0   0dN.30 400273.772118: hrtimer_cancel: hrtimer=0xf7061e80
      
      What happens is that CPU0 goes idle and invokes
      sched_clock_idle_sleep_event() which invokes sched_clock_local() and
      CPU1 runs a remote wakeup for CPU0 at the same time, which invokes
      sched_remote_clock(). The time jump gets propagated to CPU0 via
      sched_remote_clock() and stays stale on both cores for ~4 seconds.
      
      There are only two other possibilities, which could cause a stale
      sched clock:
      
      1) ktime_get() which reads out CLOCK_MONOTONIC returns a sporadic
         wrong value.
      
      2) sched_clock() which reads the TSC returns a sporadic wrong value.
      
      #1 can be excluded because sched_clock would continue to increase for
         one jiffy and then go stale.
      
      #2 can be excluded because it would not make the clock jump
         forward. It would just result in a stale sched_clock for one jiffy.
      
      After quite some brain twisting and finding the same pattern on other
      traces, sched_clock_remote() remained the only place which could cause
      such a problem and as explained above it's indeed racy on 32bit
      systems.
      
      So while on 64bit systems the readout is atomic, we need to verify the
      remote readout on 32bit machines. We need to protect the local->clock
      readout in sched_clock_remote() on 32bit as well because an NMI could
      hit between the low and the high readout, call sched_clock_local() and
      modify local->clock.
      
      Thanks to Siegfried Wulsch for bearing with my debug requests and
      going through the tedious tasks of running a bunch of reproducer
      systems to generate the debug information which let me decode the
      issue.
      Reported-by: default avatarSiegfried Wulsch <Siegfried.Wulsch@rovema.de>
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1304051544160.21884@ionosSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      [bwh: Backported to 3.2: adjust filename]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      4dfc47d2
    • Michael Wolf's avatar
      powerpc: pSeries_lpar_hpte_remove fails from Adjunct partition being performed... · 2efb2740
      Michael Wolf authored
      powerpc: pSeries_lpar_hpte_remove fails from Adjunct partition being performed before the ANDCOND test
      
      commit 9fb26401 upstream.
      
      Some versions of pHyp will perform the adjunct partition test before the
      ANDCOND test.  The result of this is that H_RESOURCE can be returned and
      cause the BUG_ON condition to occur. The HPTE is not removed.  So add a
      check for H_RESOURCE, it is ok if this HPTE is not removed as
      pSeries_lpar_hpte_remove is looking for an HPTE to remove and not a
      specific HPTE to remove.  So it is ok to just move on to the next slot
      and try again.
      Signed-off-by: default avatarMichael Wolf <mjw@linux.vnet.ibm.com>
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2efb2740
    • Jay Estabrook's avatar
      alpha: Add irongate_io to PCI bus resources · 9c7787a1
      Jay Estabrook authored
      commit aa8b4be3 upstream.
      
      Fixes a NULL pointer dereference at boot on UP1500.
      Reviewed-and-Tested-by: default avatarMatt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarJay Estabrook <jay.estabrook@gmail.com>
      Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarMichael Cree <mcree@orcon.net.nz>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      9c7787a1
    • Eldad Zack's avatar
      ALSA: usb-audio: fix endianness bug in snd_nativeinstruments_* · 74e038af
      Eldad Zack authored
      commit 889d6684 upstream.
      
      The usb_control_msg() function expects __u16 types and performs
      the endianness conversions by itself.
      However, in three places, a conversion is performed before it is
      handed over to usb_control_msg(), which leads to a double conversion
      (= no conversion):
      * snd_usb_nativeinstruments_boot_quirk()
      * snd_nativeinstruments_control_get()
      * snd_nativeinstruments_control_put()
      
      Caught by sparse:
      
      sound/usb/mixer_quirks.c:512:38: warning: incorrect type in argument 6 (different base types)
      sound/usb/mixer_quirks.c:512:38:    expected unsigned short [unsigned] [usertype] index
      sound/usb/mixer_quirks.c:512:38:    got restricted __le16 [usertype] <noident>
      sound/usb/mixer_quirks.c:543:35: warning: incorrect type in argument 5 (different base types)
      sound/usb/mixer_quirks.c:543:35:    expected unsigned short [unsigned] [usertype] value
      sound/usb/mixer_quirks.c:543:35:    got restricted __le16 [usertype] <noident>
      sound/usb/mixer_quirks.c:543:56: warning: incorrect type in argument 6 (different base types)
      sound/usb/mixer_quirks.c:543:56:    expected unsigned short [unsigned] [usertype] index
      sound/usb/mixer_quirks.c:543:56:    got restricted __le16 [usertype] <noident>
      sound/usb/quirks.c:502:35: warning: incorrect type in argument 5 (different base types)
      sound/usb/quirks.c:502:35:    expected unsigned short [unsigned] [usertype] value
      sound/usb/quirks.c:502:35:    got restricted __le16 [usertype] <noident>
      Signed-off-by: default avatarEldad Zack <eldad@fogrefinery.com>
      Acked-by: default avatarDaniel Mack <zonque@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      74e038af
    • Li Fei's avatar
      hwspinlock: fix __hwspin_lock_request error path · f7626edc
      Li Fei authored
      commit c10b90d8 upstream.
      
      Even in failed case of pm_runtime_get_sync, the usage_count
      is incremented. In order to keep the usage_count with correct
      value and runtime power management to behave correctly, call
      pm_runtime_put_noidle in such case.
      
      In __hwspin_lock_request, module_put is also called before
      return in pm_runtime_get_sync failed case.
      
      Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
      Signed-off-by: default avatarLi Fei <fei.li@intel.com>
      [edit commit log]
      Signed-off-by: default avatarOhad Ben-Cohen <ohad@wizery.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      f7626edc
    • Youquan Song's avatar
      ata_piix: Fix DVD not dectected at some Haswell platforms · e319383b
      Youquan Song authored
      commit b55f84e2 upstream.
      
      There is a quirk patch 5e5a4f5d
      "ata_piix: make DVD Drive recognisable on systems with Intel Sandybridge
       chipsets(v2)" fixing the 4 ports IDE controller 32bit PIO mode.
      
      We've hit a problem with DVD not recognized on Haswell Desktop platform which
      includes Lynx Point 2-port SATA controller.
      
      This quirk patch disables 32bit PIO on this controller in IDE mode.
      
      v2: Change spelling error in statememnt pointed by Sergei Shtylyov.
      v3: Change comment statememnt and spliting line over 80 characters pointed by
          Libor Pechacek and also rebase the patch against 3.8-rc7 kernel.
      Tested-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarYouquan Song <youquan.song@intel.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e319383b
    • Shan Hai's avatar
      libata: Set max sector to 65535 for Slimtype DVD A DS8A8SH drive · 2c10a283
      Shan Hai authored
      commit a32450e1 upstream.
      
      The Slimtype DVD A  DS8A8SH drive locks up when max sector is smaller than
      65535, and the blow backtrace is observed on locking up:
      
      INFO: task flush-8:32:1130 blocked for more than 120 seconds.
      "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      flush-8:32      D ffffffff8180cf60     0  1130      2 0x00000000
       ffff880273aef618 0000000000000046 0000000000000005 ffff880273aee000
       ffff880273aee000 ffff880273aeffd8 ffff880273aee010 ffff880273aee000
       ffff880273aeffd8 ffff880273aee000 ffff88026e842ea0 ffff880274a10000
      Call Trace:
       [<ffffffff8168fc2d>] schedule+0x5d/0x70
       [<ffffffff8168fccc>] io_schedule+0x8c/0xd0
       [<ffffffff81324461>] get_request+0x731/0x7d0
       [<ffffffff8133dc60>] ? cfq_allow_merge+0x50/0x90
       [<ffffffff81083aa0>] ? wake_up_bit+0x40/0x40
       [<ffffffff81320443>] ? bio_attempt_back_merge+0x33/0x110
       [<ffffffff813248ea>] blk_queue_bio+0x23a/0x3f0
       [<ffffffff81322176>] generic_make_request+0xc6/0x120
       [<ffffffff81322308>] submit_bio+0x138/0x160
       [<ffffffff811d7596>] ? bio_alloc_bioset+0x96/0x120
       [<ffffffff811d1f61>] submit_bh+0x1f1/0x220
       [<ffffffff811d48b8>] __block_write_full_page+0x228/0x340
       [<ffffffff811d3650>] ? attach_nobh_buffers+0xc0/0xc0
       [<ffffffff811d8960>] ? I_BDEV+0x10/0x10
       [<ffffffff811d8960>] ? I_BDEV+0x10/0x10
       [<ffffffff811d4ab6>] block_write_full_page_endio+0xe6/0x100
       [<ffffffff811d4ae5>] block_write_full_page+0x15/0x20
       [<ffffffff811d9268>] blkdev_writepage+0x18/0x20
       [<ffffffff81142527>] __writepage+0x17/0x40
       [<ffffffff811438ba>] write_cache_pages+0x34a/0x4a0
       [<ffffffff81142510>] ? set_page_dirty+0x70/0x70
       [<ffffffff81143a61>] generic_writepages+0x51/0x80
       [<ffffffff81143ab0>] do_writepages+0x20/0x50
       [<ffffffff811c9ed6>] __writeback_single_inode+0xa6/0x2b0
       [<ffffffff811ca861>] writeback_sb_inodes+0x311/0x4d0
       [<ffffffff811caaa6>] __writeback_inodes_wb+0x86/0xd0
       [<ffffffff811cad43>] wb_writeback+0x1a3/0x330
       [<ffffffff816916cf>] ? _raw_spin_lock_irqsave+0x3f/0x50
       [<ffffffff811b8362>] ? get_nr_inodes+0x52/0x70
       [<ffffffff811cb0ac>] wb_do_writeback+0x1dc/0x260
       [<ffffffff8168dd34>] ? schedule_timeout+0x204/0x240
       [<ffffffff811cb232>] bdi_writeback_thread+0x102/0x2b0
       [<ffffffff811cb130>] ? wb_do_writeback+0x260/0x260
       [<ffffffff81083550>] kthread+0xc0/0xd0
       [<ffffffff81083490>] ? kthread_worker_fn+0x1b0/0x1b0
       [<ffffffff8169a3ec>] ret_from_fork+0x7c/0xb0
       [<ffffffff81083490>] ? kthread_worker_fn+0x1b0/0x1b0
      
       The above trace was triggered by
         "dd if=/dev/zero of=/dev/sr0 bs=2048 count=32768"
      
       It was previously working by accident, since another bug introduced
       by 4dce8ba9 (libata: Use 'bool' return value for ata_id_XXX) caused
       all drives to use maxsect=65535.
      Signed-off-by: default avatarShan Hai <shan.hai@windriver.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2c10a283
    • Shan Hai's avatar
      libata: Use integer return value for atapi_command_packet_set · 274c4edc
      Shan Hai authored
      commit d8668fcb upstream.
      
      The function returns type of ATAPI drives so it should return integer value.
      The commit 4dce8ba9 (libata: Use 'bool' return value for ata_id_XXX) since
      v2.6.39 changed the type of return value from int to bool, the change would
      cause all of the ATAPI class drives to be treated as TYPE_TAPE and the
      max_sectors of the drives to be set to 65535 because of the commit
      f8d8e579(libata: increase 128 KB / cmd limit for ATAPI tape drives), for the
      function would return true for all ATAPI class drives and the TYPE_TAPE is
      defined as 0x01.
      Signed-off-by: default avatarShan Hai <shan.hai@windriver.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      274c4edc
    • Tim Gardner's avatar
      rt2x00: rt2x00pci_regbusy_read() - only print register access failure once · 61d50e12
      Tim Gardner authored
      commit 83589b30 upstream.
      
      BugLink: http://bugs.launchpad.net/bugs/1128840
      
      It appears that when this register read fails it never recovers, so
      I think there is no need to repeat the same error message ad infinitum.
      
      Cc: Ivo van Doorn <IvDoorn@gmail.com>
      Cc: Gertjan van Wingerde <gwingerde@gmail.com>
      Cc: Helmut Schaa <helmut.schaa@googlemail.com>
      Cc: "John W. Linville" <linville@tuxdriver.com>
      Cc: linux-wireless@vger.kernel.org
      Cc: users@rt2x00.serialmonkey.com
      Cc: netdev@vger.kernel.org
      Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      61d50e12
    • Jussi Kivilinna's avatar
      crypto: gcm - fix assumption that assoc has one segment · da6e577a
      Jussi Kivilinna authored
      commit d3dde522 upstream.
      
      rfc4543(gcm(*)) code for GMAC assumes that assoc scatterlist always contains
      only one segment and only makes use of this first segment. However ipsec passes
      assoc with three segments when using 'extended sequence number' thus in this
      case rfc4543(gcm(*)) fails to function correctly. Patch fixes this issue.
      Reported-by: default avatarChaoxing Lin <Chaoxing.Lin@ultra-3eti.com>
      Tested-by: default avatarChaoxing Lin <Chaoxing.Lin@ultra-3eti.com>
      Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@iki.fi>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      da6e577a
    • Michael Bohan's avatar
      hrtimer: Don't reinitialize a cpu_base lock on CPU_UP · de16cb5f
      Michael Bohan authored
      commit 84cc8fd2 upstream.
      
      The current code makes the assumption that a cpu_base lock won't be
      held if the CPU corresponding to that cpu_base is offline, which isn't
      always true.
      
      If a hrtimer is not queued, then it will not be migrated by
      migrate_hrtimers() when a CPU is offlined. Therefore, the hrtimer's
      cpu_base may still point to a CPU which has subsequently gone offline
      if the timer wasn't enqueued at the time the CPU went down.
      
      Normally this wouldn't be a problem, but a cpu_base's lock is blindly
      reinitialized each time a CPU is brought up. If a CPU is brought
      online during the period that another thread is performing a hrtimer
      operation on a stale hrtimer, then the lock will be reinitialized
      under its feet, and a SPIN_BUG() like the following will be observed:
      
      <0>[   28.082085] BUG: spinlock already unlocked on CPU#0, swapper/0/0
      <0>[   28.087078]  lock: 0xc4780b40, value 0x0 .magic: dead4ead, .owner: <none>/-1, .owner_cpu: -1
      <4>[   42.451150] [<c0014398>] (unwind_backtrace+0x0/0x120) from [<c0269220>] (do_raw_spin_unlock+0x44/0xdc)
      <4>[   42.460430] [<c0269220>] (do_raw_spin_unlock+0x44/0xdc) from [<c071b5bc>] (_raw_spin_unlock+0x8/0x30)
      <4>[   42.469632] [<c071b5bc>] (_raw_spin_unlock+0x8/0x30) from [<c00a9ce0>] (__hrtimer_start_range_ns+0x1e4/0x4f8)
      <4>[   42.479521] [<c00a9ce0>] (__hrtimer_start_range_ns+0x1e4/0x4f8) from [<c00aa014>] (hrtimer_start+0x20/0x28)
      <4>[   42.489247] [<c00aa014>] (hrtimer_start+0x20/0x28) from [<c00e6190>] (rcu_idle_enter_common+0x1ac/0x320)
      <4>[   42.498709] [<c00e6190>] (rcu_idle_enter_common+0x1ac/0x320) from [<c00e6440>] (rcu_idle_enter+0xa0/0xb8)
      <4>[   42.508259] [<c00e6440>] (rcu_idle_enter+0xa0/0xb8) from [<c000f268>] (cpu_idle+0x24/0xf0)
      <4>[   42.516503] [<c000f268>] (cpu_idle+0x24/0xf0) from [<c06ed3c0>] (rest_init+0x88/0xa0)
      <4>[   42.524319] [<c06ed3c0>] (rest_init+0x88/0xa0) from [<c0c00978>] (start_kernel+0x3d0/0x434)
      
      As an example, this particular crash occurred when hrtimer_start() was
      executed on CPU #0. The code locked the hrtimer's current cpu_base
      corresponding to CPU #1. CPU #0 then tried to switch the hrtimer's
      cpu_base to an optimal CPU which was online. In this case, it selected
      the cpu_base corresponding to CPU #3.
      
      Before it could proceed, CPU #1 came online and reinitialized the
      spinlock corresponding to its cpu_base. Thus now CPU #0 held a lock
      which was reinitialized. When CPU #0 finally ended up unlocking the
      old cpu_base corresponding to CPU #1 so that it could switch to CPU
      #3, we hit this SPIN_BUG() above while in switch_hrtimer_base().
      
      CPU #0                            CPU #1
      ----                              ----
      ...                               <offline>
      hrtimer_start()
      lock_hrtimer_base(base #1)
      ...                               init_hrtimers_cpu()
      switch_hrtimer_base()             ...
      ...                               raw_spin_lock_init(&cpu_base->lock)
      raw_spin_unlock(&cpu_base->lock)  ...
      <spin_bug>
      
      Solve this by statically initializing the lock.
      Signed-off-by: default avatarMichael Bohan <mbohan@codeaurora.org>
      Link: http://lkml.kernel.org/r/1363745965-23475-1-git-send-email-mbohan@codeaurora.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      de16cb5f
    • Johan Hovold's avatar
      USB: ti_usb_3410_5052: fix use-after-free in TIOCMIWAIT · 3668b9c1
      Johan Hovold authored
      commit fc98ab87 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3668b9c1
    • Johan Hovold's avatar
      USB: ssu100: fix use-after-free in TIOCMIWAIT · a8d64652
      Johan Hovold authored
      commit 43a66b4c upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      a8d64652
    • Johan Hovold's avatar
      USB: spcp8x5: fix use-after-free in TIOCMIWAIT · d1baabc8
      Johan Hovold authored
      commit dbcea761 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context, indentation]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      d1baabc8
    • Johan Hovold's avatar
      USB: pl2303: fix use-after-free in TIOCMIWAIT · 664e1221
      Johan Hovold authored
      commit 40509ca9 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      664e1221
    • Johan Hovold's avatar
      USB: oti6858: fix use-after-free in TIOCMIWAIT · 5db2cb16
      Johan Hovold authored
      commit 8edfdab3 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context, indentation]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5db2cb16
    • Johan Hovold's avatar
      USB: mos7840: fix use-after-free in TIOCMIWAIT · 82159cdc
      Johan Hovold authored
      commit a14430db upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      82159cdc
    • Johan Hovold's avatar
      USB: mos7840: fix broken TIOCMIWAIT · 928ab285
      Johan Hovold authored
      commit e670c6af upstream.
      
      Make sure waiting processes are woken on modem-status changes.
      
      Currently processes are only woken on termios changes regardless of
      whether the modem status has changed.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      928ab285
    • Johan Hovold's avatar
      USB: mct_u232: fix use-after-free in TIOCMIWAIT · 4f8adbff
      Johan Hovold authored
      commit cf1d2444 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      4f8adbff
    • Johan Hovold's avatar
      USB: io_ti: fix use-after-free in TIOCMIWAIT · 24d369d8
      Johan Hovold authored
      commit 7b245969 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      24d369d8
    • Johan Hovold's avatar
      USB: io_edgeport: fix use-after-free in TIOCMIWAIT · 0c384c6e
      Johan Hovold authored
      commit 33357625 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      0c384c6e
    • Johan Hovold's avatar
      USB: ftdi_sio: fix use-after-free in TIOCMIWAIT · 31b9905f
      Johan Hovold authored
      commit 71ccb9b0 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      
      When switching to tty ports, some lifetime assumptions were changed.
      Specifically, close can now be called before the final tty reference is
      dropped as part of hangup at device disconnect. Even with the ftdi
      private-data refcounting this means that the port private data can be
      freed while a process is sleeping on modem-status changes and thus
      cannot be relied on to detect disconnects when woken up.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      31b9905f
    • Johan Hovold's avatar
      USB: cypress_m8: fix use-after-free in TIOCMIWAIT · 2d5a267e
      Johan Hovold authored
      commit 356050d8 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      
      Also remove bogus test for private data pointer being NULL as it is
      never assigned in the loop.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2d5a267e