1. 26 Nov, 2012 18 commits
  2. 17 Nov, 2012 22 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.0.52 · 89d2d133
      Greg Kroah-Hartman authored
      89d2d133
    • Takashi Iwai's avatar
      ALSA: usb-audio: Fix mutex deadlock at disconnection · 09337148
      Takashi Iwai authored
      commit 10e44239 upstream.
      
      The recent change for USB-audio disconnection race fixes introduced a
      mutex deadlock again.  There is a circular dependency between
      chip->shutdown_rwsem and pcm->open_mutex, depicted like below, when a
      device is opened during the disconnection operation:
      
      A. snd_usb_audio_disconnect() ->
           card.c::register_mutex ->
             chip->shutdown_rwsem (write) ->
               snd_card_disconnect() ->
                 pcm.c::register_mutex ->
                   pcm->open_mutex
      
      B. snd_pcm_open() ->
           pcm->open_mutex ->
             snd_usb_pcm_open() ->
               chip->shutdown_rwsem (read)
      
      Since the chip->shutdown_rwsem protection in the case A is required
      only for turning on the chip->shutdown flag and it doesn't have to be
      taken for the whole operation, we can reduce its window in
      snd_usb_audio_disconnect().
      Reported-by: default avatarJiri Slaby <jslaby@suse.cz>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09337148
    • Takashi Iwai's avatar
      ALSA: Fix card refcount unbalance · aaf238ba
      Takashi Iwai authored
      commit 8bb4d9ce upstream.
      
      There are uncovered cases whether the card refcount introduced by the
      commit a0830dbd isn't properly increased or decreased:
      - OSS PCM and mixer success paths
      - When lookup function gets NULL
      
      This patch fixes these places.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=50251Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aaf238ba
    • Roland Dreier's avatar
      intel-iommu: Fix AB-BA lockdep report · 919609d3
      Roland Dreier authored
      commit 3e7abe25 upstream.
      
      When unbinding a device so that I could pass it through to a KVM VM, I
      got the lockdep report below.  It looks like a legitimate lock
      ordering problem:
      
       - domain_context_mapping_one() takes iommu->lock and calls
         iommu_support_dev_iotlb(), which takes device_domain_lock (inside
         iommu->lock).
      
       - domain_remove_one_dev_info() starts by taking device_domain_lock
         then takes iommu->lock inside it (near the end of the function).
      
      So this is the classic AB-BA deadlock.  It looks like a safe fix is to
      simply release device_domain_lock a bit earlier, since as far as I can
      tell, it doesn't protect any of the stuff accessed at the end of
      domain_remove_one_dev_info() anyway.
      
      BTW, the use of device_domain_lock looks a bit unsafe to me... it's
      at least not obvious to me why we aren't vulnerable to the race below:
      
        iommu_support_dev_iotlb()
                                                domain_remove_dev_info()
      
        lock device_domain_lock
          find info
        unlock device_domain_lock
      
                                                lock device_domain_lock
                                                  find same info
                                                unlock device_domain_lock
      
                                                free_devinfo_mem(info)
      
        do stuff with info after it's free
      
      However I don't understand the locking here well enough to know if
      this is a real problem, let alone what the best fix is.
      
      Anyway here's the full lockdep output that prompted all of this:
      
           =======================================================
           [ INFO: possible circular locking dependency detected ]
           2.6.39.1+ #1
           -------------------------------------------------------
           bash/13954 is trying to acquire lock:
            (&(&iommu->lock)->rlock){......}, at: [<ffffffff812f6421>] domain_remove_one_dev_info+0x121/0x230
      
           but task is already holding lock:
            (device_domain_lock){-.-...}, at: [<ffffffff812f6508>] domain_remove_one_dev_info+0x208/0x230
      
           which lock already depends on the new lock.
      
           the existing dependency chain (in reverse order) is:
      
           -> #1 (device_domain_lock){-.-...}:
                  [<ffffffff8109ca9d>] lock_acquire+0x9d/0x130
                  [<ffffffff81571475>] _raw_spin_lock_irqsave+0x55/0xa0
                  [<ffffffff812f8350>] domain_context_mapping_one+0x600/0x750
                  [<ffffffff812f84df>] domain_context_mapping+0x3f/0x120
                  [<ffffffff812f9175>] iommu_prepare_identity_map+0x1c5/0x1e0
                  [<ffffffff81ccf1ca>] intel_iommu_init+0x88e/0xb5e
                  [<ffffffff81cab204>] pci_iommu_init+0x16/0x41
                  [<ffffffff81002165>] do_one_initcall+0x45/0x190
                  [<ffffffff81ca3d3f>] kernel_init+0xe3/0x168
                  [<ffffffff8157ac24>] kernel_thread_helper+0x4/0x10
      
           -> #0 (&(&iommu->lock)->rlock){......}:
                  [<ffffffff8109bf3e>] __lock_acquire+0x195e/0x1e10
                  [<ffffffff8109ca9d>] lock_acquire+0x9d/0x130
                  [<ffffffff81571475>] _raw_spin_lock_irqsave+0x55/0xa0
                  [<ffffffff812f6421>] domain_remove_one_dev_info+0x121/0x230
                  [<ffffffff812f8b42>] device_notifier+0x72/0x90
                  [<ffffffff8157555c>] notifier_call_chain+0x8c/0xc0
                  [<ffffffff81089768>] __blocking_notifier_call_chain+0x78/0xb0
                  [<ffffffff810897b6>] blocking_notifier_call_chain+0x16/0x20
                  [<ffffffff81373a5c>] __device_release_driver+0xbc/0xe0
                  [<ffffffff81373ccf>] device_release_driver+0x2f/0x50
                  [<ffffffff81372ee3>] driver_unbind+0xa3/0xc0
                  [<ffffffff813724ac>] drv_attr_store+0x2c/0x30
                  [<ffffffff811e4506>] sysfs_write_file+0xe6/0x170
                  [<ffffffff8117569e>] vfs_write+0xce/0x190
                  [<ffffffff811759e4>] sys_write+0x54/0xa0
                  [<ffffffff81579a82>] system_call_fastpath+0x16/0x1b
      
           other info that might help us debug this:
      
           6 locks held by bash/13954:
            #0:  (&buffer->mutex){+.+.+.}, at: [<ffffffff811e4464>] sysfs_write_file+0x44/0x170
            #1:  (s_active#3){++++.+}, at: [<ffffffff811e44ed>] sysfs_write_file+0xcd/0x170
            #2:  (&__lockdep_no_validate__){+.+.+.}, at: [<ffffffff81372edb>] driver_unbind+0x9b/0xc0
            #3:  (&__lockdep_no_validate__){+.+.+.}, at: [<ffffffff81373cc7>] device_release_driver+0x27/0x50
            #4:  (&(&priv->bus_notifier)->rwsem){.+.+.+}, at: [<ffffffff8108974f>] __blocking_notifier_call_chain+0x5f/0xb0
            #5:  (device_domain_lock){-.-...}, at: [<ffffffff812f6508>] domain_remove_one_dev_info+0x208/0x230
      
           stack backtrace:
           Pid: 13954, comm: bash Not tainted 2.6.39.1+ #1
           Call Trace:
            [<ffffffff810993a7>] print_circular_bug+0xf7/0x100
            [<ffffffff8109bf3e>] __lock_acquire+0x195e/0x1e10
            [<ffffffff810972bd>] ? trace_hardirqs_off+0xd/0x10
            [<ffffffff8109d57d>] ? trace_hardirqs_on_caller+0x13d/0x180
            [<ffffffff8109ca9d>] lock_acquire+0x9d/0x130
            [<ffffffff812f6421>] ? domain_remove_one_dev_info+0x121/0x230
            [<ffffffff81571475>] _raw_spin_lock_irqsave+0x55/0xa0
            [<ffffffff812f6421>] ? domain_remove_one_dev_info+0x121/0x230
            [<ffffffff810972bd>] ? trace_hardirqs_off+0xd/0x10
            [<ffffffff812f6421>] domain_remove_one_dev_info+0x121/0x230
            [<ffffffff812f8b42>] device_notifier+0x72/0x90
            [<ffffffff8157555c>] notifier_call_chain+0x8c/0xc0
            [<ffffffff81089768>] __blocking_notifier_call_chain+0x78/0xb0
            [<ffffffff810897b6>] blocking_notifier_call_chain+0x16/0x20
            [<ffffffff81373a5c>] __device_release_driver+0xbc/0xe0
            [<ffffffff81373ccf>] device_release_driver+0x2f/0x50
            [<ffffffff81372ee3>] driver_unbind+0xa3/0xc0
            [<ffffffff813724ac>] drv_attr_store+0x2c/0x30
            [<ffffffff811e4506>] sysfs_write_file+0xe6/0x170
            [<ffffffff8117569e>] vfs_write+0xce/0x190
            [<ffffffff811759e4>] sys_write+0x54/0xa0
            [<ffffffff81579a82>] system_call_fastpath+0x16/0x1b
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      919609d3
    • Dave Chinner's avatar
      xfs: fix reading of wrapped log data · 11b34bb1
      Dave Chinner authored
      commit 6ce377af upstream.
      
      Commit 44396476 ("xfs: reset buffer pointers before freeing them") in
      3.0-rc1 introduced a regression when recovering log buffers that
      wrapped around the end of log. The second part of the log buffer at
      the start of the physical log was being read into the header buffer
      rather than the data buffer, and hence recovery was seeing garbage
      in the data buffer when it got to the region of the log buffer that
      was incorrectly read.
      Reported-by: default avatarTorsten Kaiser <just.for.lkml@googlemail.com>
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
      Signed-off-by: default avatarBen Myers <bpm@sgi.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      11b34bb1
    • Johan Hovold's avatar
      USB: mos7840: remove unused variable · 87725c35
      Johan Hovold authored
      Fix warning about unused variable introduced by commit e681b66f
      ("USB: mos7840: remove invalid disconnect handling") upstream.
      
      A subsequent fix which removed the disconnect function got rid of the
      warning but that one was only backported to v3.6.
      Reported-by: default avatarJiri Slaby <jslaby@suse.cz>
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87725c35
    • Daniel Vetter's avatar
      drm/i915: clear the entire sdvo infoframe buffer · b7832d49
      Daniel Vetter authored
      commit b6e0e543 upstream.
      
      Like in the case of native hdmi, which is fixed already in
      
      commit adf00b26
      Author: Paulo Zanoni <paulo.r.zanoni@intel.com>
      Date:   Tue Sep 25 13:23:34 2012 -0300
      
          drm/i915: make sure we write all the DIP data bytes
      
      we need to clear the entire sdvo buffer to avoid upsetting the
      display.
      
      Since infoframe buffer writing is now a bit more elaborate, extract it
      into it's own function. This will be useful if we ever get around to
      properly update the ELD for sdvo. Also #define proper names for the
      two buffer indexes with fixed usage.
      
      v2: Cite the right commit above, spotted by Paulo Zanoni.
      
      v3: I'm too stupid to paste the right commit.
      
      v4: Ben Hutchings noticed that I've failed to handle an underflow in
      my loop logic, breaking it for i >= length + 8. Since I've just lost C
      programmer license, use his solution. Also, make the frustrated 0-base
      buffer size a notch more clear.
      Reported-and-tested-by: default avatarJürg Billeter <j@bitron.ch>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=25732
      Cc: Paulo Zanoni <przanoni@gmail.com>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@gmail.com>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b7832d49
    • Daniel Vetter's avatar
      drm/i915: fixup infoframe support for sdvo · 9615dee4
      Daniel Vetter authored
      commit 81014b9d upstream.
      
      At least the worst offenders:
      - SDVO specifies that the encoder should compute the ecc. Testing also
        shows that we must not send the ecc field, so copy the dip_infoframe
        struct to a temporay place and avoid the ecc field. This way the avi
        infoframe is exactly 17 bytes long, which agrees with what the spec
        mandates as a minimal storage capacity (with the ecc field it would
        be 18 bytes).
      - Only 17 when sending the avi infoframe. The SDVO spec explicitly
        says that sending more data than what the device announces results
        in undefined behaviour.
      - Add __attribute__((packed)) to the avi and spd infoframes, for
        otherwise they're wrongly aligned. Noticed because the avi infoframe
        ended up being 18 bytes large instead of 17. We haven't noticed this
        yet because we don't use the uint16_t fields yet (which are the only
        ones that would be wrongly aligned).
      
      This regression has been introduce by
      
      3c17fe4b is the first bad commit
      commit 3c17fe4b
      Author: David Härdeman <david@hardeman.nu>
      Date:   Fri Sep 24 21:44:32 2010 +0200
      
          i915: enable AVI infoframe for intel_hdmi.c [v4]
      
      Patch tested on my g33 with a sdvo hdmi adaptor.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=25732
      Tested-by: Peter Ross <pross@xvid.org> (G35 SDVO-HDMI)
      Reviewed-by: default avatarEugeni Dodonov <eugeni.dodonov@intel.com>
      Signed-Off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9615dee4
    • Thomas Hellstrom's avatar
      drm/vmwgfx: Fix hibernation device reset · d18edec7
      Thomas Hellstrom authored
      commit 95e8f6a2 upstream.
      
      The device would not reset properly when resuming from hibernation.
      Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
      Reviewed-by: default avatarBrian Paul <brianp@vmware.com>
      Reviewed-by: default avatarDmitry Torokhov <dtor@vmware.com>
      Cc: linux-graphics-maintainer@vmware.com
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d18edec7
    • Thomas Gleixner's avatar
      futex: Handle futex_pi OWNER_DIED take over correctly · 2f56580d
      Thomas Gleixner authored
      commit 59fa6245 upstream.
      
      Siddhesh analyzed a failure in the take over of pi futexes in case the
      owner died and provided a workaround.
      See: http://sourceware.org/bugzilla/show_bug.cgi?id=14076
      
      The detailed problem analysis shows:
      
      Futex F is initialized with PTHREAD_PRIO_INHERIT and
      PTHREAD_MUTEX_ROBUST_NP attributes.
      
      T1 lock_futex_pi(F);
      
      T2 lock_futex_pi(F);
         --> T2 blocks on the futex and creates pi_state which is associated
             to T1.
      
      T1 exits
         --> exit_robust_list() runs
             --> Futex F userspace value TID field is set to 0 and
                 FUTEX_OWNER_DIED bit is set.
      
      T3 lock_futex_pi(F);
         --> Succeeds due to the check for F's userspace TID field == 0
         --> Claims ownership of the futex and sets its own TID into the
             userspace TID field of futex F
         --> returns to user space
      
      T1 --> exit_pi_state_list()
             --> Transfers pi_state to waiter T2 and wakes T2 via
             	   rt_mutex_unlock(&pi_state->mutex)
      
      T2 --> acquires pi_state->mutex and gains real ownership of the
             pi_state
         --> Claims ownership of the futex and sets its own TID into the
             userspace TID field of futex F
         --> returns to user space
      
      T3 --> observes inconsistent state
      
      This problem is independent of UP/SMP, preemptible/non preemptible
      kernels, or process shared vs. private. The only difference is that
      certain configurations are more likely to expose it.
      
      So as Siddhesh correctly analyzed the following check in
      futex_lock_pi_atomic() is the culprit:
      
      	if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) {
      
      We check the userspace value for a TID value of 0 and take over the
      futex unconditionally if that's true.
      
      AFAICT this check is there as it is correct for a different corner
      case of futexes: the WAITERS bit became stale.
      
      Now the proposed change
      
      -	if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) {
      +       if (unlikely(ownerdied ||
      +                       !(curval & (FUTEX_TID_MASK | FUTEX_WAITERS)))) {
      
      solves the problem, but it's not obvious why and it wreckages the
      "stale WAITERS bit" case.
      
      What happens is, that due to the WAITERS bit being set (T2 is blocked
      on that futex) it enforces T3 to go through lookup_pi_state(), which
      in the above case returns an existing pi_state and therefor forces T3
      to legitimately fight with T2 over the ownership of the pi_state (via
      pi_state->mutex). Probelm solved!
      
      Though that does not work for the "WAITERS bit is stale" problem
      because if lookup_pi_state() does not find existing pi_state it
      returns -ERSCH (due to TID == 0) which causes futex_lock_pi() to
      return -ESRCH to user space because the OWNER_DIED bit is not set.
      
      Now there is a different solution to that problem. Do not look at the
      user space value at all and enforce a lookup of possibly available
      pi_state. If pi_state can be found, then the new incoming locker T3
      blocks on that pi_state and legitimately races with T2 to acquire the
      rt_mutex and the pi_state and therefor the proper ownership of the
      user space futex.
      
      lookup_pi_state() has the correct order of checks. It first tries to
      find a pi_state associated with the user space futex and only if that
      fails it checks for futex TID value = 0. If no pi_state is available
      nothing can create new state at that point because this happens with
      the hash bucket lock held.
      
      So the above scenario changes to:
      
      T1 lock_futex_pi(F);
      
      T2 lock_futex_pi(F);
         --> T2 blocks on the futex and creates pi_state which is associated
             to T1.
      
      T1 exits
         --> exit_robust_list() runs
             --> Futex F userspace value TID field is set to 0 and
                 FUTEX_OWNER_DIED bit is set.
      
      T3 lock_futex_pi(F);
         --> Finds pi_state and blocks on pi_state->rt_mutex
      
      T1 --> exit_pi_state_list()
             --> Transfers pi_state to waiter T2 and wakes it via
             	   rt_mutex_unlock(&pi_state->mutex)
      
      T2 --> acquires pi_state->mutex and gains ownership of the pi_state
         --> Claims ownership of the futex and sets its own TID into the
             userspace TID field of futex F
         --> returns to user space
      
      This covers all gazillion points on which T3 might come in between
      T1's exit_robust_list() clearing the TID field and T2 fixing it up. It
      also solves the "WAITERS bit stale" problem by forcing the take over.
      
      Another benefit of changing the code this way is that it makes it less
      dependent on untrusted user space values and therefor minimizes the
      possible wreckage which might be inflicted.
      
      As usual after staring for too long at the futex code my brain hurts
      so much that I really want to ditch that whole optimization of
      avoiding the syscall for the non contended case for PI futexes and rip
      out the maze of corner case handling code. Unfortunately we can't as
      user space relies on that existing behaviour, but at least thinking
      about it helps me to preserve my mental sanity. Maybe we should
      nevertheless :)
      Reported-and-tested-by: default avatarSiddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
      Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1210232138540.2756@ionosAcked-by: default avatarDarren Hart <dvhart@linux.intel.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f56580d
    • Hannes Frederic Sowa's avatar
      ipv6: send unsolicited neighbour advertisements to all-nodes · 2e570a4e
      Hannes Frederic Sowa authored
      [ Upstream commit 60713a0c ]
      
      As documented in RFC4861 (Neighbor Discovery for IP version 6) 7.2.6.,
      unsolicited neighbour advertisements should be sent to the all-nodes
      multicast address.
      Signed-off-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e570a4e
    • Tom Parkin's avatar
      l2tp: fix oops in l2tp_eth_create() error path · 5a3e425d
      Tom Parkin authored
      [ Upstream commit 78933636 ]
      
      When creating an L2TPv3 Ethernet session, if register_netdev() should fail for
      any reason (for example, automatic naming for "l2tpeth%d" interfaces hits the
      32k-interface limit), the netdev is freed in the error path.  However, the
      l2tp_eth_sess structure's dev pointer is left uncleared, and this results in
      l2tp_eth_delete() then attempting to unregister the same netdev later in the
      session teardown.  This results in an oops.
      
      To avoid this, clear the session dev pointer in the error path.
      Signed-off-by: default avatarTom Parkin <tparkin@katalix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a3e425d
    • Jesper Dangaard Brouer's avatar
      net: fix divide by zero in tcp algorithm illinois · 798c7dba
      Jesper Dangaard Brouer authored
      [ Upstream commit 8f363b77 ]
      
      Reading TCP stats when using TCP Illinois congestion control algorithm
      can cause a divide by zero kernel oops.
      
      The division by zero occur in tcp_illinois_info() at:
       do_div(t, ca->cnt_rtt);
      where ca->cnt_rtt can become zero (when rtt_reset is called)
      
      Steps to Reproduce:
       1. Register tcp_illinois:
           # sysctl -w net.ipv4.tcp_congestion_control=illinois
       2. Monitor internal TCP information via command "ss -i"
           # watch -d ss -i
       3. Establish new TCP conn to machine
      
      Either it fails at the initial conn, or else it needs to wait
      for a loss or a reset.
      
      This is only related to reading stats.  The function avg_delay() also
      performs the same divide, but is guarded with a (ca->cnt_rtt > 0) at its
      calling point in update_params().  Thus, simply fix tcp_illinois_info().
      
      Function tcp_illinois_info() / get_info() is called without
      socket lock.  Thus, eliminate any race condition on ca->cnt_rtt
      by using a local stack variable.  Simply reuse info.tcpv_rttcnt,
      as its already set to ca->cnt_rtt.
      Function avg_delay() is not affected by this race condition, as
      its called with the socket lock.
      
      Cc: Petr Matousek <pmatouse@redhat.com>
      Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarStephen Hemminger <shemminger@vyatta.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      798c7dba
    • Hemant Kumar's avatar
      net: usb: Fix memory leak on Tx data path · 690bfe52
      Hemant Kumar authored
      [ Upstream commit 39707c2a ]
      
      Driver anchors the tx urbs and defers the urb submission if
      a transmit request comes when the interface is suspended.
      Anchoring urb increments the urb reference count. These
      deferred urbs are later accessed by calling usb_get_from_anchor()
      for submission during interface resume. usb_get_from_anchor()
      unanchors the urb but urb reference count remains same.
      This causes the urb reference count to remain non-zero
      after usb_free_urb() gets called and urb never gets freed.
      Hence call usb_put_urb() after anchoring the urb to properly
      balance the reference count for these deferred urbs. Also,
      unanchor these deferred urbs during disconnect, to free them
      up.
      Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
      Acked-by: default avatarOliver Neukum <oneukum@suse.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      690bfe52
    • Li RongQing's avatar
      ipv6: Set default hoplimit as zero. · db138ef2
      Li RongQing authored
      [ Upstream commit 14edd87d ]
      
      Commit a02e4b7d(Demark default hoplimit as zero) only changes the
      hoplimit checking condition and default value in ip6_dst_hoplimit, not
      zeros all hoplimit default value.
      
      Keep the zeroing ip6_template_metrics[RTAX_HOPLIMIT - 1] to force it as
      const, cause as a37e6e34(net: force dst_default_metrics to const
      section)
      Signed-off-by: default avatarLi RongQing <roy.qing.li@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      db138ef2
    • Eric Dumazet's avatar
      tcp: fix FIONREAD/SIOCINQ · 3297d60d
      Eric Dumazet authored
      [ Upstream commit a3374c42 ]
      
      tcp_ioctl() tries to take into account if tcp socket received a FIN
      to report correct number bytes in receive queue.
      
      But its flaky because if the application ate the last skb,
      we return 1 instead of 0.
      
      Correct way to detect that FIN was received is to test SOCK_DONE.
      Reported-by: default avatarElliot Hughes <enh@google.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Neal Cardwell <ncardwell@google.com>
      Cc: Tom Herbert <therbert@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3297d60d
    • Eric Dumazet's avatar
      netlink: use kfree_rcu() in netlink_release() · fdc00aba
      Eric Dumazet authored
      [ Upstream commit 6d772ac5 ]
      
      On some suspend/resume operations involving wimax device, we have
      noticed some intermittent memory corruptions in netlink code.
      
      Stéphane Marchesin tracked this corruption in netlink_update_listeners()
      and suggested a patch.
      
      It appears netlink_release() should use kfree_rcu() instead of kfree()
      for the listeners structure as it may be used by other cpus using RCU
      protection.
      
      netlink_release() must set to NULL the listeners pointer when
      it is about to be freed.
      
      Also have to protect netlink_update_listeners() and
      netlink_has_listeners() if listeners is NULL.
      
      Add a nl_deref_protected() lockdep helper to properly document which
      locks protects us.
      Reported-by: default avatarJonathan Kliegman <kliegs@google.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Stéphane Marchesin <marcheu@google.com>
      Cc: Sam Leffler <sleffler@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fdc00aba
    • Zijie Pan's avatar
      sctp: fix call to SCTP_CMD_PROCESS_SACK in sctp_cmd_interpreter() · b2327041
      Zijie Pan authored
      [ Upstream commit f6e80abe ]
      
      Bug introduced by commit edfee033
      (sctp: check src addr when processing SACK to update transport state)
      Signed-off-by: default avatarZijie Pan <zijie.pan@6wind.com>
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Acked-by: default avatarVlad Yasevich <vyasevich@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2327041
    • Takashi Iwai's avatar
      ALSA: Avoid endless sleep after disconnect · 8a7173c5
      Takashi Iwai authored
      commit 0914f796 upstream.
      
      When disconnect callback is called, each component should wake up
      sleepers and check card->shutdown flag for avoiding the endless sleep
      blocking the proper resource release.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a7173c5
    • Takashi Iwai's avatar
      ALSA: Add a reference counter to card instance · 40edba66
      Takashi Iwai authored
      commit a0830dbd upstream.
      
      For more strict protection for wild disconnections, a refcount is
      introduced to the card instance, and let it up/down when an object is
      referred via snd_lookup_*() in the open ops.
      
      The free-after-last-close check is also changed to check this refcount
      instead of the empty list, too.
      Reported-by: default avatarMatthieu CASTET <matthieu.castet@parrot.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      40edba66
    • Takashi Iwai's avatar
      ALSA: usb-audio: Fix races at disconnection in mixer_quirks.c · fb434cc2
      Takashi Iwai authored
      commit 888ea7d5 upstream.
      
      Similar like the previous commit, cover with chip->shutdown_rwsem
      and chip->shutdown checks.
      Reported-by: default avatarMatthieu CASTET <matthieu.castet@parrot.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fb434cc2
    • Takashi Iwai's avatar
      ALSA: usb-audio: Use rwsem for disconnect protection · 14565776
      Takashi Iwai authored
      commit 34f3c89f upstream.
      
      Replace mutex with rwsem for codec->shutdown protection so that
      concurrent accesses are allowed.
      
      Also add the protection to snd_usb_autosuspend() and
      snd_usb_autoresume(), too.
      Reported-by: default avatarMatthieu CASTET <matthieu.castet@parrot.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      14565776