1. 02 Apr, 2012 40 commits
    • Alex Deucher's avatar
      17ec4b6b
    • Alex Deucher's avatar
      drm/radeon/kms: fix analog load detection on DVI-I connectors · 0f745b71
      Alex Deucher authored
      commit e00e8b5e upstream.
      
      We digital encoders have a detect function as well (for
      DP to VGA bridges), so we make sure we choose the analog
      one here.
      
      Fixes:
      https://bugs.freedesktop.org/show_bug.cgi?id=47007Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0f745b71
    • Michel Dänzer's avatar
      drm/radeon: Restrict offset for legacy hardware cursor. · e6062265
      Michel Dänzer authored
      commit c4353016 upstream.
      
      The hardware only takes 27 bits for the offset, so larger offsets are
      truncated, and the hardware cursor shows random bits other than the intended
      ones.
      
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=46796Signed-off-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      e6062265
    • NeilBrown's avatar
      md/raid1,raid10: avoid deadlock during resync/recovery. · 4db1aef6
      NeilBrown authored
      commit d6b42dcb upstream.
      
      If RAID1 or RAID10 is used under LVM or some other stacking
      block device, it is possible to enter a deadlock during
      resync or recovery.
      This can happen if the upper level block device creates
      two requests to the RAID1 or RAID10.  The first request gets
      processed, blocks recovery and queue requests for underlying
      requests in current->bio_list.  A resync request then starts
      which will wait for those requests and block new IO.
      
      But then the second request to the RAID1/10 will be attempted
      and it cannot progress until the resync request completes,
      which cannot progress until the underlying device requests complete,
      which are on a queue behind that second request.
      
      So allow that second request to proceed even though there is
      a resync request about to start.
      
      This is suitable for any -stable kernel.
      Reported-by: default avatarRay Morris <support@bettercgi.com>
      Tested-by: default avatarRay Morris <support@bettercgi.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4db1aef6
    • NeilBrown's avatar
      md/bitmap: ensure to load bitmap when creating via sysfs. · 6990597d
      NeilBrown authored
      commit 4474ca42 upstream.
      
      When commit 69e51b44 (md/bitmap:  separate out loading a bitmap...)
      created bitmap_load, it missed calling it after bitmap_create when a
      bitmap is created through the sysfs interface.
      So if a bitmap is added this way, we don't allocate memory properly
      and can crash.
      
      This is suitable for any -stable release since 2.6.35.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6990597d
    • Nicholas Bellinger's avatar
      tcm_fc: Fix fc_exch memory leak in ft_send_resp_status · bf8109a3
      Nicholas Bellinger authored
      commit 031ed4d5 upstream.
      
      This patch fixes a bug in tcm_fc where fc_exch memory from fc_exch_mgr->ep_pool
      is currently being leaked by ft_send_resp_status() usage.  Following current
      code in ft_queue_status() response path, using lport->tt.seq_send() needs to be
      followed by a lport->tt.exch_done() in order to release fc_exch memory back into
      libfc_em kmem_cache.
      
      ft_send_resp_status() code is currently used in pre submit se_cmd ft_send_work()
      error exceptions, TM request setup exceptions, and main TM response callback
      path in ft_queue_tm_resp().  This bugfix addresses the leak in these cases.
      
      Cc: Mark D Rustad <mark.d.rustad@intel.com>
      Cc: Kiran Patil <kiran.patil@intel.com>
      Cc: Robert Love <robert.w.love@intel.com>
      Cc: Andy Grover <agrover@redhat.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bf8109a3
    • Kay Sievers's avatar
      udlfb: remove sysfs framebuffer device with USB .disconnect() · 6ee80c03
      Kay Sievers authored
      commit ce880cb8 upstream.
      
      The USB graphics card driver delays the unregistering of the framebuffer
      device to a workqueue, which breaks the userspace visible remove uevent
      sequence. Recent userspace tools started to support USB graphics card
      hotplug out-of-the-box and rely on proper events sent by the kernel.
      
      The framebuffer device is a direct child of the USB interface which is
      removed immediately after the USB .disconnect() callback. But the fb device
      in /sys stays around until its final cleanup, at a time where all the parent
      devices have been removed already.
      
      To work around that, we remove the sysfs fb device directly in the USB
      .disconnect() callback and leave only the cleanup of the internal fb
      data to the delayed work.
      
      Before:
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/graphics/fb0 (graphics)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
       remove   /2-1.2:1.0/graphics/fb0 (graphics)
      
      After:
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
       add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/graphics/fb1 (graphics)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/graphics/fb1 (graphics)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
       remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
      Tested-by: default avatarBernie Thompson <bernie@plugable.com>
      Acked-by: default avatarBernie Thompson <bernie@plugable.com>
      Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ee80c03
    • Roland Dreier's avatar
      tcm_loop: Set residual field for SCSI commands · bbcf567a
      Roland Dreier authored
      commit 6cf3fa69 upstream.
      
      If the target core signals an over- or under-run, tcm_loop should call
      scsi_set_resid() to tell the SCSI midlayer about the residual data length.
      
      The difference can be seen by doing something like
      
          strace -eioctl sg_raw -r 1024 /dev/sda 8 0 0 0 1 0 > /dev/null
      
      and looking at the "resid=" part of the SG_IO ioctl -- after this patch,
      the field is correctly reported as 512.
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbcf567a
    • Daniel Mack's avatar
      ASoC: pxa-ssp: atomically set stream active masks · bb4b4709
      Daniel Mack authored
      commit 273b72c8 upstream.
      
      PXA's SSP engine fails to take its current channel phase into account
      when enabling a stream while the engine is already running. This
      results in randomly swapped left/right channels on either the record
      or the playback side, depending on which one was enabled first.
      
      The following patch fixes this by factoring out the bit field
      modifications in question to a separate function that pauses the
      engine temporarily, modifies the bits and kicks it off again
      afterwards. Appearantly, a transition of SSCR0_SSE syncs both
      directions properly.
      
      The patch has been rolled out to quite a number of devices over the
      last weeks and seems to fix the issue reliably.
      Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
      Reported-and-tested-by: default avatarSven Neumann <s.neumann@raumfeld.com>
      Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb4b4709
    • Aneesh Kumar K.V's avatar
      hugetlbfs: avoid taking i_mutex from hugetlbfs_read() · b113a5a2
      Aneesh Kumar K.V authored
      commit a05b0855 upstream.
      
      Taking i_mutex in hugetlbfs_read() can result in deadlock with mmap as
      explained below
      
       Thread A:
        read() on hugetlbfs
         hugetlbfs_read() called
          i_mutex grabbed
           hugetlbfs_read_actor() called
            __copy_to_user() called
             page fault is triggered
       Thread B, sharing address space with A:
        mmap() the same file
         ->mmap_sem is grabbed on task_B->mm->mmap_sem
          hugetlbfs_file_mmap() is called
           attempt to grab ->i_mutex and block waiting for A to give it up
       Thread A:
        pagefault handled blocked on attempt to grab task_A->mm->mmap_sem,
       which happens to be the same thing as task_B->mm->mmap_sem.  Block waiting
       for B to give it up.
      
      AFAIU the i_mutex locking was added to hugetlbfs_read() as per
      http://lkml.indiana.edu/hypermail/linux/kernel/0707.2/3066.html to take
      care of the race between truncate and read.  This patch fixes this by
      looking at page->mapping under lock_page() (find_lock_page()) to ensure
      that the inode didn't get truncated in the range during a parallel read.
      
      Ideally we can extend the patch to make sure we don't increase i_size in
      mmap.  But that will break userspace, because applications will now have
      to use truncate(2) to increase i_size in hugetlbfs.
      
      Based on the original patch from Hillf Danton.
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Hillf Danton <dhillf@gmail.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Hugh Dickins <hughd@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b113a5a2
    • Nishanth Aravamudan's avatar
      bootmem/sparsemem: remove limit constraint in alloc_bootmem_section · 59d76fa1
      Nishanth Aravamudan authored
      commit f5bf18fa upstream.
      
      While testing AMS (Active Memory Sharing) / CMO (Cooperative Memory
      Overcommit) on powerpc, we tripped the following:
      
        kernel BUG at mm/bootmem.c:483!
        cpu 0x0: Vector: 700 (Program Check) at [c000000000c03940]
            pc: c000000000a62bd8: .alloc_bootmem_core+0x90/0x39c
            lr: c000000000a64bcc: .sparse_early_usemaps_alloc_node+0x84/0x29c
            sp: c000000000c03bc0
           msr: 8000000000021032
          current = 0xc000000000b0cce0
          paca    = 0xc000000001d80000
            pid   = 0, comm = swapper
        kernel BUG at mm/bootmem.c:483!
        enter ? for help
        [c000000000c03c80] c000000000a64bcc
        .sparse_early_usemaps_alloc_node+0x84/0x29c
        [c000000000c03d50] c000000000a64f10 .sparse_init+0x12c/0x28c
        [c000000000c03e20] c000000000a474f4 .setup_arch+0x20c/0x294
        [c000000000c03ee0] c000000000a4079c .start_kernel+0xb4/0x460
        [c000000000c03f90] c000000000009670 .start_here_common+0x1c/0x2c
      
      This is
      
              BUG_ON(limit && goal + size > limit);
      
      and after some debugging, it seems that
      
      	goal = 0x7ffff000000
      	limit = 0x80000000000
      
      and sparse_early_usemaps_alloc_node ->
      sparse_early_usemaps_alloc_pgdat_section calls
      
      	return alloc_bootmem_section(usemap_size() * count, section_nr);
      
      This is on a system with 8TB available via the AMS pool, and as a quirk
      of AMS in firmware, all of that memory shows up in node 0.  So, we end
      up with an allocation that will fail the goal/limit constraints.
      
      In theory, we could "fall-back" to alloc_bootmem_node() in
      sparse_early_usemaps_alloc_node(), but since we actually have HOTREMOVE
      defined, we'll BUG_ON() instead.  A simple solution appears to be to
      unconditionally remove the limit condition in alloc_bootmem_section,
      meaning allocations are allowed to cross section boundaries (necessary
      for systems of this size).
      
      Johannes Weiner pointed out that if alloc_bootmem_section() no longer
      guarantees section-locality, we need check_usemap_section_nr() to print
      possible cross-dependencies between node descriptors and the usemaps
      allocated through it.  That makes the two loops in
      sparse_early_usemaps_alloc_node() identical, so re-factor the code a
      bit.
      
      [akpm@linux-foundation.org: code simplification]
      Signed-off-by: default avatarNishanth Aravamudan <nacc@us.ibm.com>
      Cc: Dave Hansen <haveblue@us.ibm.com>
      Cc: Anton Blanchard <anton@au1.ibm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Ben Herrenschmidt <benh@kernel.crashing.org>
      Cc: Robert Jennings <rcj@linux.vnet.ibm.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarMel Gorman <mgorman@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      59d76fa1
    • Andrea Arcangeli's avatar
      mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode · 5a3e1f55
      Andrea Arcangeli authored
      commit 1a5a9906 upstream.
      
      In some cases it may happen that pmd_none_or_clear_bad() is called with
      the mmap_sem hold in read mode.  In those cases the huge page faults can
      allocate hugepmds under pmd_none_or_clear_bad() and that can trigger a
      false positive from pmd_bad() that will not like to see a pmd
      materializing as trans huge.
      
      It's not khugepaged causing the problem, khugepaged holds the mmap_sem
      in write mode (and all those sites must hold the mmap_sem in read mode
      to prevent pagetables to go away from under them, during code review it
      seems vm86 mode on 32bit kernels requires that too unless it's
      restricted to 1 thread per process or UP builds).  The race is only with
      the huge pagefaults that can convert a pmd_none() into a
      pmd_trans_huge().
      
      Effectively all these pmd_none_or_clear_bad() sites running with
      mmap_sem in read mode are somewhat speculative with the page faults, and
      the result is always undefined when they run simultaneously.  This is
      probably why it wasn't common to run into this.  For example if the
      madvise(MADV_DONTNEED) runs zap_page_range() shortly before the page
      fault, the hugepage will not be zapped, if the page fault runs first it
      will be zapped.
      
      Altering pmd_bad() not to error out if it finds hugepmds won't be enough
      to fix this, because zap_pmd_range would then proceed to call
      zap_pte_range (which would be incorrect if the pmd become a
      pmd_trans_huge()).
      
      The simplest way to fix this is to read the pmd in the local stack
      (regardless of what we read, no need of actual CPU barriers, only
      compiler barrier needed), and be sure it is not changing under the code
      that computes its value.  Even if the real pmd is changing under the
      value we hold on the stack, we don't care.  If we actually end up in
      zap_pte_range it means the pmd was not none already and it was not huge,
      and it can't become huge from under us (khugepaged locking explained
      above).
      
      All we need is to enforce that there is no way anymore that in a code
      path like below, pmd_trans_huge can be false, but pmd_none_or_clear_bad
      can run into a hugepmd.  The overhead of a barrier() is just a compiler
      tweak and should not be measurable (I only added it for THP builds).  I
      don't exclude different compiler versions may have prevented the race
      too by caching the value of *pmd on the stack (that hasn't been
      verified, but it wouldn't be impossible considering
      pmd_none_or_clear_bad, pmd_bad, pmd_trans_huge, pmd_none are all inlines
      and there's no external function called in between pmd_trans_huge and
      pmd_none_or_clear_bad).
      
      		if (pmd_trans_huge(*pmd)) {
      			if (next-addr != HPAGE_PMD_SIZE) {
      				VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem));
      				split_huge_page_pmd(vma->vm_mm, pmd);
      			} else if (zap_huge_pmd(tlb, vma, pmd, addr))
      				continue;
      			/* fall through */
      		}
      		if (pmd_none_or_clear_bad(pmd))
      
      Because this race condition could be exercised without special
      privileges this was reported in CVE-2012-1179.
      
      The race was identified and fully explained by Ulrich who debugged it.
      I'm quoting his accurate explanation below, for reference.
      
      ====== start quote =======
            mapcount 0 page_mapcount 1
            kernel BUG at mm/huge_memory.c:1384!
      
          At some point prior to the panic, a "bad pmd ..." message similar to the
          following is logged on the console:
      
            mm/memory.c:145: bad pmd ffff8800376e1f98(80000000314000e7).
      
          The "bad pmd ..." message is logged by pmd_clear_bad() before it clears
          the page's PMD table entry.
      
              143 void pmd_clear_bad(pmd_t *pmd)
              144 {
          ->  145         pmd_ERROR(*pmd);
              146         pmd_clear(pmd);
              147 }
      
          After the PMD table entry has been cleared, there is an inconsistency
          between the actual number of PMD table entries that are mapping the page
          and the page's map count (_mapcount field in struct page). When the page
          is subsequently reclaimed, __split_huge_page() detects this inconsistency.
      
             1381         if (mapcount != page_mapcount(page))
             1382                 printk(KERN_ERR "mapcount %d page_mapcount %d\n",
             1383                        mapcount, page_mapcount(page));
          -> 1384         BUG_ON(mapcount != page_mapcount(page));
      
          The root cause of the problem is a race of two threads in a multithreaded
          process. Thread B incurs a page fault on a virtual address that has never
          been accessed (PMD entry is zero) while Thread A is executing an madvise()
          system call on a virtual address within the same 2 MB (huge page) range.
      
                     virtual address space
                    .---------------------.
                    |                     |
                    |                     |
                  .-|---------------------|
                  | |                     |
                  | |                     |<-- B(fault)
                  | |                     |
            2 MB  | |/////////////////////|-.
            huge <  |/////////////////////|  > A(range)
            page  | |/////////////////////|-'
                  | |                     |
                  | |                     |
                  '-|---------------------|
                    |                     |
                    |                     |
                    '---------------------'
      
          - Thread A is executing an madvise(..., MADV_DONTNEED) system call
            on the virtual address range "A(range)" shown in the picture.
      
          sys_madvise
            // Acquire the semaphore in shared mode.
            down_read(&current->mm->mmap_sem)
            ...
            madvise_vma
              switch (behavior)
              case MADV_DONTNEED:
                   madvise_dontneed
                     zap_page_range
                       unmap_vmas
                         unmap_page_range
                           zap_pud_range
                             zap_pmd_range
                               //
                               // Assume that this huge page has never been accessed.
                               // I.e. content of the PMD entry is zero (not mapped).
                               //
                               if (pmd_trans_huge(*pmd)) {
                                   // We don't get here due to the above assumption.
                               }
                               //
                               // Assume that Thread B incurred a page fault and
                   .---------> // sneaks in here as shown below.
                   |           //
                   |           if (pmd_none_or_clear_bad(pmd))
                   |               {
                   |                 if (unlikely(pmd_bad(*pmd)))
                   |                     pmd_clear_bad
                   |                     {
                   |                       pmd_ERROR
                   |                         // Log "bad pmd ..." message here.
                   |                       pmd_clear
                   |                         // Clear the page's PMD entry.
                   |                         // Thread B incremented the map count
                   |                         // in page_add_new_anon_rmap(), but
                   |                         // now the page is no longer mapped
                   |                         // by a PMD entry (-> inconsistency).
                   |                     }
                   |               }
                   |
                   v
          - Thread B is handling a page fault on virtual address "B(fault)" shown
            in the picture.
      
          ...
          do_page_fault
            __do_page_fault
              // Acquire the semaphore in shared mode.
              down_read_trylock(&mm->mmap_sem)
              ...
              handle_mm_fault
                if (pmd_none(*pmd) && transparent_hugepage_enabled(vma))
                    // We get here due to the above assumption (PMD entry is zero).
                    do_huge_pmd_anonymous_page
                      alloc_hugepage_vma
                        // Allocate a new transparent huge page here.
                      ...
                      __do_huge_pmd_anonymous_page
                        ...
                        spin_lock(&mm->page_table_lock)
                        ...
                        page_add_new_anon_rmap
                          // Here we increment the page's map count (starts at -1).
                          atomic_set(&page->_mapcount, 0)
                        set_pmd_at
                          // Here we set the page's PMD entry which will be cleared
                          // when Thread A calls pmd_clear_bad().
                        ...
                        spin_unlock(&mm->page_table_lock)
      
          The mmap_sem does not prevent the race because both threads are acquiring
          it in shared mode (down_read).  Thread B holds the page_table_lock while
          the page's map count and PMD table entry are updated.  However, Thread A
          does not synchronize on that lock.
      
      ====== end quote =======
      
      [akpm@linux-foundation.org: checkpatch fixes]
      Reported-by: default avatarUlrich Obergfell <uobergfe@redhat.com>
      Signed-off-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Dave Jones <davej@redhat.com>
      Acked-by: default avatarLarry Woodman <lwoodman@redhat.com>
      Acked-by: default avatarRik van Riel <riel@redhat.com>
      Cc: Mark Salter <msalter@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a3e1f55
    • Suresh Siddha's avatar
      x86/ioapic: Add register level checks to detect bogus io-apic entries · c2ec63ed
      Suresh Siddha authored
      commit 73d63d03 upstream.
      
      With the recent changes to clear_IO_APIC_pin() which tries to
      clear remoteIRR bit explicitly, some of the users started to see
      "Unable to reset IRR for apic .." messages.
      
      Close look shows that these are related to bogus IO-APIC entries
      which return's all 1's for their io-apic registers. And the
      above mentioned error messages are benign. But kernel should
      have ignored such io-apic's in the first place.
      
      Check if register 0, 1, 2 of the listed io-apic are all 1's and
      ignore such io-apic.
      Reported-by: default avatarÁlvaro Castillo <midgoon@gmail.com>
      Tested-by: default avatarJon Dufresne <jon@jondufresne.org>
      Signed-off-by: default avatarSuresh Siddha <suresh.b.siddha@intel.com>
      Cc: yinghai@kernel.org
      Cc: kernel-team@fedoraproject.org
      Cc: Josh Boyer <jwboyer@redhat.com>
      Link: http://lkml.kernel.org/r/1331577393.31585.94.camel@sbsiddha-desk.sc.intel.com
      [ Performed minor cleanup of affected code. ]
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2ec63ed
    • Or Gerlitz's avatar
      IB/iser: Post initial receive buffers before sending the final login request · ec97d16d
      Or Gerlitz authored
      commit 89e984e2 upstream.
      
      An iser target may send iscsi NO-OP PDUs as soon as it marks the iSER
      iSCSI session as fully operative.  This means that there is window
      where there are no posted receive buffers on the initiator side, so
      it's possible for the iSER RC connection to break because of RNR NAK /
      retry errors.  To fix this, rely on the flags bits in the login
      request to have FFP (0x3) in the lower nibble as a marker for the
      final login request, and post an initial chunk of receive buffers
      before sending that login request instead of after getting the login
      response.
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec97d16d
    • Max Filippov's avatar
      p54spi: Release GPIO lines and IRQ on error in p54spi_probe · 2a367a76
      Max Filippov authored
      commit 62ebeed8 upstream.
      
      This makes it possible to reload driver if insmod has failed due to
      missing firmware.
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Acked-by: default avatarChristian Lamparter <chunkeey@googlemail.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a367a76
    • Rabin Vincent's avatar
      rtc: Disable the alarm in the hardware (v2) · 220b62b4
      Rabin Vincent authored
      commit 41c7f742 upstream.
      
      Currently, the RTC code does not disable the alarm in the hardware.
      
      This means that after a sequence such as the one below (the files are in the
      RTC sysfs), the box will boot up after 2 minutes even though we've
      asked for the alarm to be turned off.
      
      	# echo $((`cat since_epoch`)+120) > wakealarm
      	# echo 0 > wakealarm
      	# poweroff
      
      Fix this by disabling the alarm when there are no timers to run.
      
      The original version of this patch was reverted. This version
      disables the irq directly instead of setting a disabled timer
      in the future.
      
      Cc: John Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarRabin Vincent <rabin.vincent@stericsson.com>
      [Merged in the second revision from Rabin]
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      220b62b4
    • Alexander Gordeev's avatar
      genirq: Fix incorrect check for forced IRQ thread handler · e48530f7
      Alexander Gordeev authored
      commit 540b60e2 upstream.
      
      We do not want a bitwise AND between boolean operands
      Signed-off-by: default avatarAlexander Gordeev <agordeev@redhat.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Link: http://lkml.kernel.org/r/20120309135912.GA2114@dhcp-26-207.brq.redhat.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e48530f7
    • Russell King's avatar
      genirq: Fix long-term regression in genirq irq_set_irq_type() handling · 3f64d9ec
      Russell King authored
      commit a09b659c upstream.
      
      In 2008, commit 0c5d1eb7 ("genirq: record trigger type") modified the
      way set_irq_type() handles the 'no trigger' condition.  However, this has
      an adverse effect on PCMCIA support on Intel StrongARM and probably PXA
      platforms.
      
      PCMCIA has several status signals on the socket which can trigger
      interrupts; some of these status signals depend on the card's mode
      (whether it is configured in memory or IO mode).  For example, cards have
      a 'Ready/IRQ' signal: in memory mode, this provides an indication to
      PCMCIA that the card has finished its power up initialization.  In IO
      mode, it provides the device interrupt signal.  Other status signals
      switch between on-board battery status and loud speaker output.
      
      In classical PCMCIA implementations, where you have a specific socket
      controller, the controller provides a method to mask interrupts from the
      socket, and importantly ignore any state transitions on the pins which
      correspond with interrupts once masked.  This masking prevents unwanted
      events caused by the removal and application of socket power being
      forwarded.
      
      However, on platforms where there is no socket controller, the PCMCIA
      status and interrupt signals are routed to standard edge-triggered GPIOs.
      These GPIOs can be configured to interrupt on rising edge, falling edge,
      or never.  This is where the problems start.
      
      Edge triggered interrupts are required to record events while disabled via
      the usual methods of {free,request,disable,enable}_irq() to prevent
      problems with dropped interrupts (eg, the 8390 driver uses disable_irq()
      to defer the delivery of interrupts).  As a result, these interfaces can
      not be used to implement the desired behaviour.
      
      The side effect of this is that if the 'Ready/IRQ' GPIO is disabled via
      disable_irq() on suspend, and enabled via enable_irq() after resume, we
      will record the state transitions caused by powering events as valid
      interrupts, and foward them to the card driver, which may attempt to
      access a card which is not powered up.
      
      This leads delays resume while drivers spin in their interrupt handlers,
      and complaints from drivers before they realize what's happened.
      
      Moreover, in the case of the 'Ready/IRQ' signal, this is requested and
      freed by the card driver itself; the PCMCIA core has no idea whether the
      interrupt is requested, and, therefore, whether a call to disable_irq()
      would be valid.  (We tried this around 2.4.17 / 2.5.1 kernel era, and
      ended up throwing it out because of this problem.)
      
      Therefore, it was decided back in around 2002 to disable the edge
      triggering instead, resulting in all state transitions on the GPIO being
      ignored.  That's what we actually need the hardware to do.
      
      The commit above changes this behaviour; it explicitly prevents the 'no
      trigger' state being selected.
      
      The reason that request_irq() does not accept the 'no trigger' state is
      for compatibility with existing drivers which do not provide their desired
      triggering configuration.  The set_irq_type() function is 'new' and not
      used by non-trigger aware drivers.
      
      Therefore, revert this change, and restore previously working platforms
      back to their former state.
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Cc: linux@arm.linux.org.uk
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f64d9ec
    • Andrew Vagin's avatar
      uevent: send events in correct order according to seqnum (v3) · 377c2f4a
      Andrew Vagin authored
      commit 7b60a18d upstream.
      
      The queue handling in the udev daemon assumes that the events are
      ordered.
      
      Before this patch uevent_seqnum is incremented under sequence_lock,
      than an event is send uner uevent_sock_mutex. I want to say that code
      contained a window between incrementing seqnum and sending an event.
      
      This patch locks uevent_sock_mutex before incrementing uevent_seqnum.
      
      v2: delete sequence_lock, uevent_seqnum is protected by uevent_sock_mutex
      v3: unlock the mutex before the goto exit
      
      Thanks for Kay for the comments.
      Signed-off-by: default avatarAndrew Vagin <avagin@openvz.org>
      Tested-By: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      377c2f4a
    • Sasha Levin's avatar
      ntp: Fix integer overflow when setting time · d16d493a
      Sasha Levin authored
      commit a078c6d0 upstream.
      
      'long secs' is passed as divisor to div_s64, which accepts a 32bit
      divisor. On 64bit machines that value is trimmed back from 8 bytes
      back to 4, causing a divide by zero when the number is bigger than
      (1 << 32) - 1 and all 32 lower bits are 0.
      
      Use div64_long() instead.
      Signed-off-by: default avatarSasha Levin <levinsasha928@gmail.com>
      Cc: johnstul@us.ibm.com
      Link: http://lkml.kernel.org/r/1331829374-31543-2-git-send-email-levinsasha928@gmail.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d16d493a
    • Sasha Levin's avatar
      math: Introduce div64_long · 6368b042
      Sasha Levin authored
      commit f910381a upstream.
      
      Add a div64_long macro which is used to devide a 64bit number by a long (which
      can be 4 bytes on 32bit systems and 8 bytes on 64bit systems).
      Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarSasha Levin <levinsasha928@gmail.com>
      Cc: johnstul@us.ibm.com
      Link: http://lkml.kernel.org/r/1331829374-31543-1-git-send-email-levinsasha928@gmail.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6368b042
    • Jingjun Wu's avatar
      rtlwifi: rtl8192ce: Fix loss of receive performance · 75e37531
      Jingjun Wu authored
      commit a9b89e25 upstream.
      
      Driver rtl8192ce when used with the RTL8188CE device would start at about
      20 Mbps on a 54 Mbps connection, but quickly drop to 1 Mbps. One of the
      symptoms is that the AP would need to retransmit each packet 4 of 5 times
      before the driver would acknowledge it. Recovery is possible only by
      unloading and reloading the driver. This problem was reported at
      https://bugzilla.redhat.com/show_bug.cgi?id=770207.
      
      The problem is due to a missing update of the gain setting.
      Signed-off-by: default avatarJingjun Wu <jingjun_wu@realsil.com.cn>
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75e37531
    • Larry Finger's avatar
      rtlwifi: rtl8192c: Prevent sleeping from invalid context in rtl8192cu · debc5a0e
      Larry Finger authored
      commit ebecdcc1 upstream.
      
      When driver rtl8192cu is used with the debug level set to 3 or greater,
      the result is "sleeping function called from invalid context" due to
      an rcu_read_lock() call in the DM refresh routine in driver rtl8192c.
      This lock is not necessary as the USB driver does not use the struct
      being protected, thus the lock is set only when a PCI interface is
      active.
      
      This bug is reported in https://bugzilla.kernel.org/show_bug.cgi?id=42775.
      Reported-by: default avatarRonald Wahl <ronald.wahl@raritan.com>
      Tested-by: default avatarRonald Wahl <ronald.wahl@raritan.com>
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Cc: Ronald Wahl <ronald.wahl@raritan.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      debc5a0e
    • Simon Graham's avatar
      rtlwifi: Handle previous allocation failures when freeing device memory · 8400bf92
      Simon Graham authored
      commit 7f66c2f9 upstream.
      
      Handle previous allocation failures when freeing device memory
      Signed-off-by: default avatarSimon Graham <simon.graham@virtualcomputer.com>
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8400bf92
    • Gertjan van Wingerde's avatar
      dc1c756a
    • Donald Lee's avatar
      USB: serial: mos7840: Fixed MCS7820 device attach problem · 9ab3ea7c
      Donald Lee authored
      commit 093ea2d3 upstream.
      
      A MCS7820 device supports two serial ports and a MCS7840 device supports
      four serial ports. Both devices use the same driver, but the attach function
      in driver was unable to correctly handle the port numbers for MCS7820
      device. This problem has been fixed in this patch and this fix has been
      verified on x86 Linux kernel 3.2.9 with both MCS7820 and MCS7840 devices.
      Signed-off-by: default avatarDonald Lee <donald@asix.com.tw>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ab3ea7c
    • Preston Fick's avatar
      usb: cp210x: Update to support CP2105 and multiple interface devices · 765d0ce6
      Preston Fick authored
      commit a5360a53 upstream.
      
      This patch updates the cp210x driver to support CP210x multiple
      interface devices devices from Silicon Labs. The existing driver
      always sends control requests to interface 0, which is hardcoded in
      the usb_control_msg function calls. This only allows for single
      interface devices to be used, and causes a bug when using ports on an
      interface other than 0 in the multiple interface devices.
      
      Here are the changes included in this patch:
      - Updated the device list to contain the Silicon Labs factory default
        VID/PID for multiple interface CP210x devices
      - Created a cp210x_port_private struct created for each port on
        startup, this struct holds the interface number
      - Added a cp210x_release function to clean up the cp210x_port_private
        memory created on startup
      - Modified usb_get_config and usb_set_config to get a pointer to the
        cp210x_port_private struct, and use the interface number there in the
        usb_control_message wIndex param
      Signed-off-by: default avatarPreston Fick <preston.fick@silabs.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      765d0ce6
    • Scott Dial's avatar
      usb-serial: Add support for the Sealevel SeaLINK+8 2038-ROHS device · 2e9bffdc
      Scott Dial authored
      commit 6d161b99 upstream.
      
      This patch adds new device IDs to the ftdi_sio module to support
      the new Sealevel SeaLINK+8 2038-ROHS device.
      Signed-off-by: default avatarScott Dial <scott.dial@scientiallc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e9bffdc
    • Dan Williams's avatar
      USB: qcserial: don't grab QMI port on Gobi 1000 devices · d03769fc
      Dan Williams authored
      commit c192c8e7 upstream.
      
      Gobi 1000 devices have a different port layout, which wasn't respected
      by the current driver, and thus it grabbed the QMI/net port.  In the
      near future we'll be attaching another driver to the QMI/net port for
      these devices (cdc-wdm and qmi_wwan) so make sure the qcserial driver
      doesn't claim them.  This patch also prevents qcserial from binding to
      interfaces 0 and 1 on 1K devices because those interfaces do not
      respond.
      Signed-off-by: default avatarDan Williams <dcbw@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d03769fc
    • Thomas Tuttle's avatar
      USB: qcserial: add several new serial devices · a93dc3f4
      Thomas Tuttle authored
      commit 2db4d870 upstream.
      Signed-off-by: default avatarThomas Tuttle <ttuttle@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      a93dc3f4
    • Peter Chen's avatar
      usb: Fix build error due to dma_mask is not at pdev_archdata at ARM · d39514c1
      Peter Chen authored
      commit e90fc3cb upstream.
      
      When build i.mx platform with imx_v6_v7_defconfig, and after adding
      USB Gadget support, it has below build error:
      
      CC      drivers/usb/host/fsl-mph-dr-of.o
      drivers/usb/host/fsl-mph-dr-of.c: In function 'fsl_usb2_device_register':
      drivers/usb/host/fsl-mph-dr-of.c:97: error: 'struct pdev_archdata'
      has no member named 'dma_mask'
      
      It has discussed at: http://www.spinics.net/lists/linux-usb/msg57302.html
      
      For PowerPC, there is dma_mask at struct pdev_archdata, but there is
      no dma_mask at struct pdev_archdata for ARM. The pdev_archdata is
      related to specific platform, it should NOT be accessed by
      cross platform drivers, like USB.
      
      The code for pdev_archdata should be useless, as for PowerPC,
      it has already gotten the value for pdev->dev.dma_mask at function
      arch_setup_pdev_archdata of arch/powerpc/kernel/setup-common.c.
      Tested-by: default avatarRamneek Mehresh <ramneek.mehresh@freescale.com>
      Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d39514c1
    • Peter Chen's avatar
      usb: fsl_udc_core: Fix scheduling while atomic dump message · cb733bd2
      Peter Chen authored
      commit c5cc5ed8 upstream.
      
      When loading g_ether gadget, there is below message:
      
      Backtrace:
      [<80012248>] (dump_backtrace+0x0/0x10c) from [<803cb42c>] (dump_stack+0x18/0x1c)
      r7:00000000 r6:80512000 r5:8052bef8 r4:80513f30
      [<803cb414>] (dump_stack+0x0/0x1c) from [<8000feb4>] (show_regs+0x44/0x50)
      [<8000fe70>] (show_regs+0x0/0x50) from [<8004c840>] (__schedule_bug+0x68/0x84)
      r5:8052bef8 r4:80513f30
      [<8004c7d8>] (__schedule_bug+0x0/0x84) from [<803cd0e4>] (__schedule+0x4b0/0x528)
      r5:8052bef8 r4:809aad00
      [<803ccc34>] (__schedule+0x0/0x528) from [<803cd214>] (_cond_resched+0x44/0x58)
      [<803cd1d0>] (_cond_resched+0x0/0x58) from [<800a9488>] (dma_pool_alloc+0x184/0x250)
       r5:9f9b4000 r4:9fb4fb80
       [<800a9304>] (dma_pool_alloc+0x0/0x250) from [<802a8ad8>] (fsl_req_to_dtd+0xac/0x180)
      [<802a8a2c>] (fsl_req_to_dtd+0x0/0x180) from [<802a8ce4>] (fsl_ep_queue+0x138/0x274)
      [<802a8bac>] (fsl_ep_queue+0x0/0x274) from [<7f004328>] (composite_setup+0x2d4/0xfac [g_ether])
      [<7f004054>] (composite_setup+0x0/0xfac [g_ether]) from [<802a9bb4>] (fsl_udc_irq+0x8dc/0xd38)
      [<802a92d8>] (fsl_udc_irq+0x0/0xd38) from [<800704f8>] (handle_irq_event_percpu+0x54/0x188)
      [<800704a4>] (handle_irq_event_percpu+0x0/0x188) from [<80070674>] (handle_irq_event+0x48/0x68)
      [<8007062c>] (handle_irq_event+0x0/0x68) from [<800738ec>] (handle_level_irq+0xb4/0x138)
       r5:80514f94 r4:80514f40
       [<80073838>] (handle_level_irq+0x0/0x138) from [<8006ffa4>] (generic_handle_irq+0x38/0x44)
       r7:00000012 r6:80510b1c r5:80529860 r4:80512000
       [<8006ff6c>] (generic_handle_irq+0x0/0x44) from [<8000f4c4>] (handle_IRQ+0x54/0xb4)
      [<8000f470>] (handle_IRQ+0x0/0xb4) from [<800085b8>] (tzic_handle_irq+0x64/0x94)
       r9:412fc085 r8:00000000 r7:80513f30 r6:00000001 r5:00000000
       r4:00000000
       [<80008554>] (tzic_handle_irq+0x0/0x94) from [<8000e680>] (__irq_svc+0x40/0x60)
      
      The reason of above dump message is calling dma_poll_alloc with can-schedule
      mem_flags at atomic context.
      
      To fix this problem, below changes are made:
      - fsl_req_to_dtd doesn't need to be protected by spin_lock_irqsave,
      as struct usb_request can be access at process context. Move lock
      to beginning of hardware visit (fsl_queue_td).
      - Change the memory flag which using to allocate dTD descriptor buffer,
      the memory flag can be from gadget layer.
      
      It is tested at i.mx51 bbg board with g_mass_storage, g_ether, g_serial.
      Signed-off-by: default avatarPeter Chen <peter.chen@freescale.com>
      Acked-by: default avatarLi Yang <leoli@freescale.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb733bd2
    • Ben Hutchings's avatar
      cdc-wdm: Don't clear WDM_READ unless entire read buffer is emptied · e6d2220d
      Ben Hutchings authored
      commit b7a20554 upstream.
      
      The WDM_READ flag is cleared later iff desc->length is reduced to 0.
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Tested-by: default avatarBjørn Mork <bjorn@mork.no>
      Cc: Oliver Neukum <oliver@neukum.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e6d2220d
    • Ben Hutchings's avatar
      cdc-wdm: Fix more races on the read path · 3b804c7c
      Ben Hutchings authored
      commit 711c68b3 upstream.
      
      We must not allow the input buffer length to change while we're
      shuffling the buffer contents.  We also mustn't clear the WDM_READ
      flag after more data might have arrived.  Therefore move both of these
      into the spinlocked region at the bottom of wdm_read().
      
      When reading desc->length without holding the iuspin lock, use
      ACCESS_ONCE() to ensure the compiler doesn't re-read it with
      inconsistent results.
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Tested-by: default avatarBjørn Mork <bjorn@mork.no>
      Cc: Oliver Neukum <oliver@neukum.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3b804c7c
    • Johan Hovold's avatar
      USB: serial: fix console error reporting · a4b9552b
      Johan Hovold authored
      commit 548dd4b6 upstream.
      
      Do not report errors in write path if port is used as a console as this
      may trigger the same error (and error report) resulting in a loop.
      Reported-by: default avatarStephen Hemminger <shemminger@vyatta.com>
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4b9552b
    • Liz Clark's avatar
      TTY: Wrong unicode value copied in con_set_unimap() · eb49cf6c
      Liz Clark authored
      commit 4a4c61b7 upstream.
      
      Bugzilla 40012: PIO_UNIMAP bug: error updating Unicode-to-font map
      https://bugzilla.kernel.org/show_bug.cgi?id=40012
      
      The unicode font map for the virtual console is a 32x32x64 table which
      allocates rows dynamically as entries are added.  The unicode value
      increases sequentially and should count all entries even in empty
      rows.  The defect is when copying the unicode font map in con_set_unimap(),
      the unicode value is not incremented properly.  The wrong unicode value
      is entered in the new font map.
      Signed-off-by: default avatarLiz Clark <liz.clark@hp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eb49cf6c
    • Dan Carpenter's avatar
      tty: moxa: fix bit test in moxa_start() · 3fc869e8
      Dan Carpenter authored
      commit 58112dfb upstream.
      
      This is supposed to be doing a shift before the comparison instead of
      just doing a bitwise AND directly.  The current code means the start()
      just returns without doing anything.
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarJiri Slaby <jslaby@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3fc869e8
    • Masami Ichikawa's avatar
      sysfs: Fix memory leak in sysfs_sd_setsecdata(). · ac51a34e
      Masami Ichikawa authored
      commit 93518dd2 upstream.
      
      This patch fixies follwing two memory leak patterns that reported by kmemleak.
      sysfs_sd_setsecdata() is called during sys_lsetxattr() operation.
      It checks sd->s_iattr is NULL or not. Then if it is NULL, it calls
      sysfs_init_inode_attrs() to allocate memory.
      That code is this.
      
      iattrs = sd->s_iattr;
      if (!iattrs)
                      iattrs = sysfs_init_inode_attrs(sd);
      
      The iattrs recieves sysfs_init_inode_attrs()'s result,  but sd->s_iattr
      doesn't know the address. so it needs to set correct address to
      sd->s_iattr to free memory in other function.
      
      unreferenced object 0xffff880250b73e60 (size 32):
        comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
        hex dump (first 32 bytes):
          73 79 73 74 65 6d 5f 75 3a 6f 62 6a 65 63 74 5f  system_u:object_
          72 3a 73 79 73 66 73 5f 74 3a 73 30 00 00 00 00  r:sysfs_t:s0....
        backtrace:
          [<ffffffff814cb1d0>] kmemleak_alloc+0x73/0x98
          [<ffffffff811270ab>] __kmalloc+0x100/0x12c
          [<ffffffff8120775a>] context_struct_to_string+0x106/0x210
          [<ffffffff81207cc1>] security_sid_to_context_core+0x10b/0x129
          [<ffffffff812090ef>] security_sid_to_context+0x10/0x12
          [<ffffffff811fb0da>] selinux_inode_getsecurity+0x7d/0xa8
          [<ffffffff811fb127>] selinux_inode_getsecctx+0x22/0x2e
          [<ffffffff811f4d62>] security_inode_getsecctx+0x16/0x18
          [<ffffffff81191dad>] sysfs_setxattr+0x96/0x117
          [<ffffffff811542f0>] __vfs_setxattr_noperm+0x73/0xd9
          [<ffffffff811543d9>] vfs_setxattr+0x83/0xa1
          [<ffffffff811544c6>] setxattr+0xcf/0x101
          [<ffffffff81154745>] sys_lsetxattr+0x6a/0x8f
          [<ffffffff814efda9>] system_call_fastpath+0x16/0x1b
          [<ffffffffffffffff>] 0xffffffffffffffff
      unreferenced object 0xffff88024163c5a0 (size 96):
        comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
        hex dump (first 32 bytes):
          00 00 00 00 ed 41 00 00 00 00 00 00 00 00 00 00  .....A..........
          00 00 00 00 00 00 00 00 0c 64 42 4f 00 00 00 00  .........dBO....
        backtrace:
          [<ffffffff814cb1d0>] kmemleak_alloc+0x73/0x98
          [<ffffffff81127402>] kmem_cache_alloc_trace+0xc4/0xee
          [<ffffffff81191cbe>] sysfs_init_inode_attrs+0x2a/0x83
          [<ffffffff81191dd6>] sysfs_setxattr+0xbf/0x117
          [<ffffffff811542f0>] __vfs_setxattr_noperm+0x73/0xd9
          [<ffffffff811543d9>] vfs_setxattr+0x83/0xa1
          [<ffffffff811544c6>] setxattr+0xcf/0x101
          [<ffffffff81154745>] sys_lsetxattr+0x6a/0x8f
          [<ffffffff814efda9>] system_call_fastpath+0x16/0x1b
          [<ffffffffffffffff>] 0xffffffffffffffff
      `
      Signed-off-by: default avatarMasami Ichikawa <masami256@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac51a34e
    • Thomas Gleixner's avatar
      futex: Cover all PI opcodes with cmpxchg enabled check · be455802
      Thomas Gleixner authored
      commit 59263b51 upstream.
      
      Some of the newer futex PI opcodes do not check the cmpxchg enabled
      variable and call unconditionally into the handling functions. Cover
      all PI opcodes in a separate check.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Darren Hart <dvhart@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be455802
    • Orjan Friberg's avatar
      USB: gadget: Make g_hid device class conform to spec. · c924f401
      Orjan Friberg authored
      commit 33d2832a upstream.
      
      HID devices should specify this in their interface descriptors, not in the
      device descriptor. This fixes a "missing hardware id" bug under Windows 7 with
      a VIA VL800 (3.0) controller.
      Signed-off-by: default avatarOrjan Friberg <of@flatfrog.com>
      Cc: Felipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c924f401