1. 13 Nov, 2014 40 commits
    • Felipe Balbi's avatar
      usb: gadget: udc: core: fix kernel oops with soft-connect · 76475a69
      Felipe Balbi authored
      [ Upstream commit bfa6b18c ]
      
      Currently, there's no guarantee that udc->driver
      will be valid when using soft_connect sysfs
      interface. In fact, we can very easily trigger
      a NULL pointer dereference by trying to disconnect
      when a gadget driver isn't loaded.
      
      Fix this bug:
      
      ~# echo disconnect > soft_connect
      [   33.685743] Unable to handle kernel NULL pointer dereference at virtual address 00000014
      [   33.694221] pgd = ed0cc000
      [   33.697174] [00000014] *pgd=ae351831, *pte=00000000, *ppte=00000000
      [   33.703766] Internal error: Oops: 17 [#1] SMP ARM
      [   33.708697] Modules linked in: xhci_plat_hcd xhci_hcd snd_soc_davinci_mcasp snd_soc_tlv320aic3x snd_soc_edma snd_soc_omap snd_soc_evm snd_soc_core dwc3 snd_compress snd_pcm_dmaengine snd_pcm snd_timer snd lis3lv02d_i2c matrix_keypad lis3lv02d dwc3_omap input_polldev soundcore
      [   33.734372] CPU: 0 PID: 1457 Comm: bash Not tainted 3.17.0-09740-ga93416e-dirty #345
      [   33.742457] task: ee71ce00 ti: ee68a000 task.ti: ee68a000
      [   33.748116] PC is at usb_udc_softconn_store+0xa4/0xec
      [   33.753416] LR is at mark_held_locks+0x78/0x90
      [   33.758057] pc : [<c04df128>]    lr : [<c00896a4>]    psr: 20000013
      [   33.758057] sp : ee68bec8  ip : c0c00008  fp : ee68bee4
      [   33.770050] r10: ee6b394c  r9 : ee68bf80  r8 : ee6062c0
      [   33.775508] r7 : 00000000  r6 : ee6062c0  r5 : 0000000b  r4 : ee739408
      [   33.782346] r3 : 00000000  r2 : 00000000  r1 : ee71d390  r0 : ee664170
      [   33.789168] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
      [   33.796636] Control: 10c5387d  Table: ad0cc059  DAC: 00000015
      [   33.802638] Process bash (pid: 1457, stack limit = 0xee68a248)
      [   33.808740] Stack: (0xee68bec8 to 0xee68c000)
      [   33.813299] bec0:                   0000000b c0411284 ee6062c0 00000000 ee68bef4 ee68bee8
      [   33.821862] bee0: c04112ac c04df090 ee68bf14 ee68bef8 c01c2868 c0411290 0000000b ee6b3940
      [   33.830419] bf00: 00000000 00000000 ee68bf4c ee68bf18 c01c1a24 c01c2818 00000000 00000000
      [   33.838990] bf20: ee61b940 ee2f47c0 0000000b 000ce408 ee68bf80 c000f304 ee68a000 00000000
      [   33.847544] bf40: ee68bf7c ee68bf50 c0152dd8 c01c1960 ee68bf7c c0170af8 ee68bf7c ee2f47c0
      [   33.856099] bf60: ee2f47c0 000ce408 0000000b c000f304 ee68bfa4 ee68bf80 c0153330 c0152d34
      [   33.864653] bf80: 00000000 00000000 0000000b 000ce408 b6e7fb50 00000004 00000000 ee68bfa8
      [   33.873204] bfa0: c000f080 c01532e8 0000000b 000ce408 00000001 000ce408 0000000b 00000000
      [   33.881763] bfc0: 0000000b 000ce408 b6e7fb50 00000004 0000000b 00000000 000c5758 00000000
      [   33.890319] bfe0: 00000000 bec2c924 b6de422d b6e1d226 40000030 00000001 75716d2f 00657565
      [   33.898890] [<c04df128>] (usb_udc_softconn_store) from [<c04112ac>] (dev_attr_store+0x28/0x34)
      [   33.907920] [<c04112ac>] (dev_attr_store) from [<c01c2868>] (sysfs_kf_write+0x5c/0x60)
      [   33.916200] [<c01c2868>] (sysfs_kf_write) from [<c01c1a24>] (kernfs_fop_write+0xd0/0x194)
      [   33.924773] [<c01c1a24>] (kernfs_fop_write) from [<c0152dd8>] (vfs_write+0xb0/0x1bc)
      [   33.932874] [<c0152dd8>] (vfs_write) from [<c0153330>] (SyS_write+0x54/0xb0)
      [   33.940247] [<c0153330>] (SyS_write) from [<c000f080>] (ret_fast_syscall+0x0/0x48)
      [   33.948160] Code: e1a01007 e12fff33 e5140004 e5143008 (e5933014)
      [   33.954625] ---[ end trace f849bead94eab7ea ]---
      
      Fixes: 2ccea03a (usb: gadget: introduce UDC Class)
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      76475a69
    • Felipe Balbi's avatar
      usb: gadget: function: acm: make f_acm pass USB20CV Chapter9 · 19342b6d
      Felipe Balbi authored
      [ Upstream commit 52ec49a5 ]
      
      During Halt Endpoint Test, our interrupt endpoint
      will be disabled, which will clear out ep->desc
      to NULL. Unless we call config_ep_by_speed() again,
      we will not be able to enable this endpoint which
      will make us fail that test.
      
      Fixes: f9c56cdd (usb: gadget: Clear usb_endpoint_descriptor
      	inside the struct usb_ep on disable)
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      19342b6d
    • Felipe Balbi's avatar
      usb: dwc3: gadget: fix set_halt() bug with pending transfers · 4220f3ff
      Felipe Balbi authored
      [ Upstream commit 7a608559 ]
      
      According to our Gadget Framework API documentation,
      ->set_halt() *must* return -EAGAIN if we have pending
      transfers (on either direction) or FIFO isn't empty (on
      TX endpoints).
      
      Fix this bug so that the mass storage gadget can be used
      without stall=0 parameter.
      
      This patch should be backported to all kernels since v3.2.
      Suggested-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      4220f3ff
    • Ondrej Kozina's avatar
      crypto: algif - avoid excessive use of socket buffer in skcipher · d87f96cc
      Ondrej Kozina authored
      commit e2cffb5f upstream.
      
      On archs with PAGE_SIZE >= 64 KiB the function skcipher_alloc_sgl()
      fails with -ENOMEM no matter what user space actually requested.
      This is caused by the fact sock_kmalloc call inside the function tried
      to allocate more memory than allowed by the default kernel socket buffer
      size (kernel param net.core.optmem_max).
      Signed-off-by: default avatarOndrej Kozina <okozina@redhat.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      d87f96cc
    • Jan Kara's avatar
      mm: Remove false WARN_ON from pagecache_isize_extended() · 50c36a9a
      Jan Kara authored
      commit f55fefd1 upstream.
      
      The WARN_ON checking whether i_mutex is held in
      pagecache_isize_extended() was wrong because some filesystems (e.g.
      XFS) use different locks for serialization of truncates / writes. So
      just remove the check.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      50c36a9a
    • Andy Lutomirski's avatar
      x86, apic: Handle a bad TSC more gracefully · 4d54f12d
      Andy Lutomirski authored
      commit b47dcbdc upstream.
      
      If the TSC is unusable or disabled, then this patch fixes:
      
       - Confusion while trying to clear old APIC interrupts.
       - Division by zero and incorrect programming of the TSC deadline
         timer.
      
      This fixes boot if the CPU has a TSC deadline timer but a missing or
      broken TSC.  The failure to boot can be observed with qemu using
      -cpu qemu64,-tsc,+tsc-deadline
      
      This also happens to me in nested KVM for unknown reasons.
      With this patch, I can boot cleanly (although without a TSC).
      Signed-off-by: default avatarAndy Lutomirski <luto@amacapital.net>
      Cc: Bandan Das <bsd@redhat.com>
      Link: http://lkml.kernel.org/r/e2fa274e498c33988efac0ba8b7e3120f7f92d78.1413393027.git.luto@amacapital.netSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      4d54f12d
    • Mathias Krause's avatar
      posix-timers: Fix stack info leak in timer_create() · 5bc8c3bd
      Mathias Krause authored
      commit 6891c450 upstream.
      
      If userland creates a timer without specifying a sigevent info, we'll
      create one ourself, using a stack local variable. Particularly will we
      use the timer ID as sival_int. But as sigev_value is a union containing
      a pointer and an int, that assignment will only partially initialize
      sigev_value on systems where the size of a pointer is bigger than the
      size of an int. On such systems we'll copy the uninitialized stack bytes
      from the timer_create() call to userland when the timer actually fires
      and we're going to deliver the signal.
      
      Initialize sigev_value with 0 to plug the stack info leak.
      
      Found in the PaX patch, written by the PaX Team.
      
      Fixes: 5a9fa730 ("posix-timers: kill ->it_sigev_signo and...")
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Brad Spengler <spender@grsecurity.net>
      Cc: PaX Team <pageexec@freemail.hu>
      Link: http://lkml.kernel.org/r/1412456799-32339-1-git-send-email-minipli@googlemail.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      5bc8c3bd
    • Karl Beldan's avatar
      mac80211: fix typo in starting baserate for rts_cts_rate_idx · 94f13cde
      Karl Beldan authored
      commit c7abf25a upstream.
      
      It affects non-(V)HT rates and can lead to selecting an rts_cts rate
      that is not a basic rate or way superior to the reference rate (ATM
      rates[0] used for the 1st attempt of the protected frame data).
      
      E.g, assuming drivers register growing (bitrate) sorted tables of
      ieee80211_rate-s, having :
      - rates[0].idx == d'2 and basic_rates == b'10100
      will select rts_cts idx b'10011 & ~d'(BIT(2)-1), i.e. 1, likewise
      - rates[0].idx == d'2 and basic_rates == b'10001
      will select rts_cts idx b'10000
      The first is not a basic rate and the second is > rates[0].
      
      Also, wrt severity of the addressed misbehavior, ATM we only have one
      rts_cts_rate_idx rather than one per rate table entry, so this idx might
      still point to bitrates > rates[1..MAX_RATES].
      
      Fixes: 5253ffb8 ("mac80211: always pick a basic rate to tx RTS/CTS for pre-HT rates")
      Signed-off-by: default avatarKarl Beldan <karl.beldan@rivierawaves.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      94f13cde
    • Imre Deak's avatar
      PM / Sleep: fix recovery during resuming from hibernation · f40d1458
      Imre Deak authored
      commit 94fb823f upstream.
      
      If a device's dev_pm_ops::freeze callback fails during the QUIESCE
      phase, we don't rollback things correctly calling the thaw and complete
      callbacks. This could leave some devices in a suspended state in case of
      an error during resuming from hibernation.
      Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      f40d1458
    • Peter Hurley's avatar
      tty: Fix high cpu load if tty is unreleaseable · 866f9fec
      Peter Hurley authored
      commit 37b16457 upstream.
      
      Kernel oops can cause the tty to be unreleaseable (for example, if
      n_tty_read() crashes while on the read_wait queue). This will cause
      tty_release() to endlessly loop without sleeping.
      
      Use a killable sleep timeout which grows by 2n+1 jiffies over the interval
      [0, 120 secs.) and then jumps to forever (but still killable).
      
      NB: killable just allows for the task to be rewoken manually, not
      to be terminated.
      Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      866f9fec
    • Eric Sandeen's avatar
      xfs: avoid false quotacheck after unclean shutdown · 0277558a
      Eric Sandeen authored
      commit 5ef828c4 upstream.
      
      The commit
      
      83e782e1 xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
      
      added a new function xfs_sb_quota_from_disk() which swaps
      on-disk XFS_OQUOTA_* flags for in-core XFS_GQUOTA_* and XFS_PQUOTA_*
      flags after the superblock is read.
      
      However, if log recovery is required, the superblock is read again,
      and the modified in-core flags are re-read from disk, so we have
      XFS_OQUOTA_* flags in memory again.  This causes the
      XFS_QM_NEED_QUOTACHECK() test to be true, because the XFS_OQUOTA_CHKD
      is still set, and not XFS_GQUOTA_CHKD or XFS_PQUOTA_CHKD.
      
      Change xfs_sb_from_disk to call xfs_sb_quota_from disk and always
      convert the disk flags to in-memory flags.
      
      Add a lower-level function which can be called with "false" to
      not convert the flags, so that the sb verifier can verify
      exactly what was on disk, per Brian Foster's suggestion.
      Reported-by: default avatarCyril B. <cbay@excellency.fr>
      Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
      Cc: Arkadiusz Miśkiewicz <arekm@maven.pl>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      0277558a
    • Jan Kara's avatar
      quota: Properly return errors from dquot_writeback_dquots() · 27612dd4
      Jan Kara authored
      commit 474d2605 upstream.
      
      Due to a switched left and right side of an assignment,
      dquot_writeback_dquots() never returned error. This could result in
      errors during quota writeback to not be reported to userspace properly.
      Fix it.
      
      Coverity-id: 1226884
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      27612dd4
    • Jan Kara's avatar
      ext3: Don't check quota format when there are no quota files · 5cc34e7c
      Jan Kara authored
      commit 7938db44 upstream.
      
      The check whether quota format is set even though there are no
      quota files with journalled quota is pointless and it actually
      makes it impossible to turn off journalled quotas (as there's
      no way to unset journalled quota format). Just remove the check.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      5cc34e7c
    • J. Bruce Fields's avatar
      nfsd4: fix crash on unknown operation number · 613a5ea5
      J. Bruce Fields authored
      commit 51904b08 upstream.
      
      Unknown operation numbers are caught in nfsd4_decode_compound() which
      sets op->opnum to OP_ILLEGAL and op->status to nfserr_op_illegal.  The
      error causes the main loop in nfsd4_proc_compound() to skip most
      processing.  But nfsd4_proc_compound also peeks ahead at the next
      operation in one case and doesn't take similar precautions there.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      613a5ea5
    • Jason Baron's avatar
      cpc925_edac: Report UE events properly · de351259
      Jason Baron authored
      commit fa19ac4b upstream.
      
      Fix UE event being reported as HW_EVENT_ERR_CORRECTED.
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Link: http://lkml.kernel.org/r/8beb13803500076fef827eab33d523e355d83759.1413405053.git.jbaron@akamai.comSigned-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      de351259
    • Jason Baron's avatar
      e7xxx_edac: Report CE events properly · 1b01c44d
      Jason Baron authored
      commit 8030122a upstream.
      
      Fix CE event being reported as HW_EVENT_ERR_UNCORRECTED.
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Link: http://lkml.kernel.org/r/e6dd616f2cd51583a7e77af6f639b86313c74144.1413405053.git.jbaron@akamai.comSigned-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      1b01c44d
    • Jason Baron's avatar
      i3200_edac: Report CE events properly · d13055e4
      Jason Baron authored
      commit 8a3f075d upstream.
      
      Fix CE event being reported as HW_EVENT_ERR_UNCORRECTED.
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Link: http://lkml.kernel.org/r/d02465b4f30314b390c12c061502eda5e9d29c52.1413405053.git.jbaron@akamai.comSigned-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      d13055e4
    • Jason Baron's avatar
      i82860_edac: Report CE events properly · fad5bfc9
      Jason Baron authored
      commit ab0543de upstream.
      
      Fix CE event being reported as HW_EVENT_ERR_UNCORRECTED.
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Link: http://lkml.kernel.org/r/7aee8e244a32ff86b399a8f966c4aae70296aae0.1413405053.git.jbaron@akamai.comSigned-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      fad5bfc9
    • Jan Kara's avatar
      scsi: Fix error handling in SCSI_IOCTL_SEND_COMMAND · e00e9894
      Jan Kara authored
      commit 84ce0f0e upstream.
      
      When sg_scsi_ioctl() fails to prepare request to submit in
      blk_rq_map_kern() we jump to a label where we just end up copying
      (luckily zeroed-out) kernel buffer to userspace instead of reporting
      error. Fix the problem by jumping to the right label.
      
      CC: Jens Axboe <axboe@kernel.dk>
      CC: linux-scsi@vger.kernel.org
      Coverity-id: 1226871
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      
      Fixed up the, now unused, out label.
      Signed-off-by: default avatarJens Axboe <axboe@fb.com>
      e00e9894
    • Jan Kara's avatar
      lib/bitmap.c: fix undefined shift in __bitmap_shift_{left|right}() · 001172f9
      Jan Kara authored
      commit ea5d05b3 upstream.
      
      If __bitmap_shift_left() or __bitmap_shift_right() are asked to shift by
      a multiple of BITS_PER_LONG, they will try to shift a long value by
      BITS_PER_LONG bits which is undefined.  Change the functions to avoid
      the undefined shift.
      
      Coverity id: 1192175
      Coverity id: 1192174
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      001172f9
    • Wang Nan's avatar
      cgroup/kmemleak: add kmemleak_free() for cgroup deallocations. · e005085a
      Wang Nan authored
      commit 401507d6 upstream.
      
      Commit ff7ee93f ("cgroup/kmemleak: Annotate alloc_page() for cgroup
      allocations") introduces kmemleak_alloc() for alloc_page_cgroup(), but
      corresponding kmemleak_free() is missing, which makes kmemleak be
      wrongly disabled after memory offlining.  Log is pasted at the end of
      this commit message.
      
      This patch add kmemleak_free() into free_page_cgroup().  During page
      offlining, this patch removes corresponding entries in kmemleak rbtree.
      After that, the freed memory can be allocated again by other subsystems
      without killing kmemleak.
      
        bash # for x in 1 2 3 4; do echo offline > /sys/devices/system/memory/memory$x/state ; sleep 1; done ; dmesg | grep leak
      
        Offlined Pages 32768
        kmemleak: Cannot insert 0xffff880016969000 into the object search tree (overlaps existing)
        CPU: 0 PID: 412 Comm: sleep Not tainted 3.17.0-rc5+ #86
        Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
        Call Trace:
          dump_stack+0x46/0x58
          create_object+0x266/0x2c0
          kmemleak_alloc+0x26/0x50
          kmem_cache_alloc+0xd3/0x160
          __sigqueue_alloc+0x49/0xd0
          __send_signal+0xcb/0x410
          send_signal+0x45/0x90
          __group_send_sig_info+0x13/0x20
          do_notify_parent+0x1bb/0x260
          do_exit+0x767/0xa40
          do_group_exit+0x44/0xa0
          SyS_exit_group+0x17/0x20
          system_call_fastpath+0x16/0x1b
      
        kmemleak: Kernel memory leak detector disabled
        kmemleak: Object 0xffff880016900000 (size 524288):
        kmemleak:   comm "swapper/0", pid 0, jiffies 4294667296
        kmemleak:   min_count = 0
        kmemleak:   count = 0
        kmemleak:   flags = 0x1
        kmemleak:   checksum = 0
        kmemleak:   backtrace:
              log_early+0x63/0x77
              kmemleak_alloc+0x4b/0x50
              init_section_page_cgroup+0x7f/0xf5
              page_cgroup_init+0xc5/0xd0
              start_kernel+0x333/0x408
              x86_64_start_reservations+0x2a/0x2c
              x86_64_start_kernel+0xf5/0xfc
      
      Fixes: ff7ee93f (cgroup/kmemleak: Annotate alloc_page() for cgroup allocations)
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.cz>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      e005085a
    • Yu Zhao's avatar
      mm: free compound page with correct order · ce55507d
      Yu Zhao authored
      commit 5ddacbe9 upstream.
      
      Compound page should be freed by put_page() or free_pages() with correct
      order.  Not doing so will cause tail pages leaked.
      
      The compound order can be obtained by compound_order() or use
      HPAGE_PMD_ORDER in our case.  Some people would argue the latter is
      faster but I prefer the former which is more general.
      
      This bug was observed not just on our servers (the worst case we saw is
      11G leaked on a 48G machine) but also on our workstations running Ubuntu
      based distro.
      
        $ cat /proc/vmstat  | grep thp_zero_page_alloc
        thp_zero_page_alloc 55
        thp_zero_page_alloc_failed 0
      
      This means there is (thp_zero_page_alloc - 1) * (2M - 4K) memory leaked.
      
      Fixes: 97ae1749 ("thp: implement refcounting for huge zero page")
      Signed-off-by: default avatarYu Zhao <yuzhao@google.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Mel Gorman <mel@csn.ul.ie>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Bob Liu <lliubbo@gmail.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 avatarJiri Slaby <jslaby@suse.cz>
      ce55507d
    • Johan Hovold's avatar
      USB: kobil_sct: fix non-atomic allocation in write path · b67eae08
      Johan Hovold authored
      commit 19125283 upstream.
      
      Write may be called from interrupt context so make sure to use
      GFP_ATOMIC for all allocations in write.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      b67eae08
    • Hans de Goede's avatar
      usb: Do not allow usb_alloc_streams on unconfigured devices · bfdb4179
      Hans de Goede authored
      commit 90a646c7 upstream.
      
      This commit fixes the following oops:
      
      [10238.622067] scsi host3: uas_eh_bus_reset_handler start
      [10240.766164] usb 3-4: reset SuperSpeed USB device number 3 using xhci_hcd
      [10245.779365] usb 3-4: device descriptor read/8, error -110
      [10245.883331] usb 3-4: reset SuperSpeed USB device number 3 using xhci_hcd
      [10250.897603] usb 3-4: device descriptor read/8, error -110
      [10251.058200] BUG: unable to handle kernel NULL pointer dereference at  0000000000000040
      [10251.058244] IP: [<ffffffff815ac6e1>] xhci_check_streams_endpoint+0x91/0x140
      <snip>
      [10251.059473] Call Trace:
      [10251.059487]  [<ffffffff815aca6c>] xhci_calculate_streams_and_bitmask+0xbc/0x130
      [10251.059520]  [<ffffffff815aeb5f>] xhci_alloc_streams+0x10f/0x5a0
      [10251.059548]  [<ffffffff810a4685>] ? check_preempt_curr+0x75/0xa0
      [10251.059575]  [<ffffffff810a46dc>] ? ttwu_do_wakeup+0x2c/0x100
      [10251.059601]  [<ffffffff810a49e6>] ? ttwu_do_activate.constprop.111+0x66/0x70
      [10251.059635]  [<ffffffff815779ab>] usb_alloc_streams+0xab/0xf0
      [10251.059662]  [<ffffffffc0616b48>] uas_configure_endpoints+0x128/0x150 [uas]
      [10251.059694]  [<ffffffffc0616bac>] uas_post_reset+0x3c/0xb0 [uas]
      [10251.059722]  [<ffffffff815727d9>] usb_reset_device+0x1b9/0x2a0
      [10251.059749]  [<ffffffffc0616f42>] uas_eh_bus_reset_handler+0xb2/0x190 [uas]
      [10251.059781]  [<ffffffff81514293>] scsi_try_bus_reset+0x53/0x110
      [10251.059808]  [<ffffffff815163b7>] scsi_eh_bus_reset+0xf7/0x270
      <snip>
      
      The problem is the following call sequence (simplified):
      
      1) usb_reset_device
      2)  usb_reset_and_verify_device
      2)   hub_port_init
      3)    hub_port_finish_reset
      3)     xhci_discover_or_reset_device
              This frees xhci->devs[slot_id]->eps[ep_index].ring for all eps but 0
      4)    usb_get_device_descriptor
             This fails
      5)   hub_port_init fails
      6)  usb_reset_and_verify_device fails, does not restore device config
      7)  uas_post_reset
      8)   xhci_alloc_streams
            NULL deref on the free-ed ring
      
      This commit fixes this by not allowing usb_alloc_streams to continue if
      the device is not configured.
      
      Note that we do allow usb_free_streams to continue after a (logical)
      disconnect, as it is necessary to explicitly free the streams at the xhci
      controller level.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      bfdb4179
    • Johan Hovold's avatar
      USB: opticon: fix non-atomic allocation in write path · b7b72e58
      Johan Hovold authored
      commit e681286d upstream.
      
      Write may be called from interrupt context so make sure to use
      GFP_ATOMIC for all allocations in write.
      
      Fixes: 0d930e51 ("USB: opticon: Add Opticon OPN2001 write support")
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      b7b72e58
    • Alan Stern's avatar
      usb-storage: handle a skipped data phase · 2aa22734
      Alan Stern authored
      commit 93c9bf4d upstream.
      
      Sometimes mass-storage devices using the Bulk-only transport will
      mistakenly skip the data phase of a command.  Rather than sending the
      data expected by the host or sending a zero-length packet, they go
      directly to the status phase and send the CSW.
      
      This causes problems for usb-storage, for obvious reasons.  The driver
      will interpret the CSW as a short data transfer and will wait to
      receive a CSW.  The device won't have anything left to send, so the
      command eventually times out.
      
      The SCSI layer doesn't retry commands after they time out (this is a
      relatively recent change).  Therefore we should do our best to detect
      a skipped data phase and handle it promptly.
      
      This patch adds code to do that.  If usb-storage receives a short
      13-byte data transfer from the device, and if the first four bytes of
      the data match the CSW signature, the driver will set the residue to
      the full transfer length and interpret the data as a CSW.
      
      This fixes Bugzilla #86611.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Tested-by: default avatarPaul Osmialowski <newchief@king.net.pl>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      2aa22734
    • Takashi Iwai's avatar
      ALSA: usb-audio: Fix device_del() sysfs warnings at disconnect · 2dbb38ff
      Takashi Iwai authored
      commit 0725dda2 upstream.
      
      Some USB-audio devices show weird sysfs warnings at disconnecting the
      devices, e.g.
       usb 1-3: USB disconnect, device number 3
       ------------[ cut here ]------------
       WARNING: CPU: 0 PID: 973 at fs/sysfs/group.c:216 device_del+0x39/0x180()
       sysfs group ffffffff8183df40 not found for kobject 'midiC1D0'
       Call Trace:
        [<ffffffff814a3e38>] ? dump_stack+0x49/0x71
        [<ffffffff8103cb72>] ? warn_slowpath_common+0x82/0xb0
        [<ffffffff8103cc55>] ? warn_slowpath_fmt+0x45/0x50
        [<ffffffff813521e9>] ? device_del+0x39/0x180
        [<ffffffff81352339>] ? device_unregister+0x9/0x20
        [<ffffffff81352384>] ? device_destroy+0x34/0x40
        [<ffffffffa00ba29f>] ? snd_unregister_device+0x7f/0xd0 [snd]
        [<ffffffffa025124e>] ? snd_rawmidi_dev_disconnect+0xce/0x100 [snd_rawmidi]
        [<ffffffffa00c0192>] ? snd_device_disconnect+0x62/0x90 [snd]
        [<ffffffffa00c025c>] ? snd_device_disconnect_all+0x3c/0x60 [snd]
        [<ffffffffa00bb574>] ? snd_card_disconnect+0x124/0x1a0 [snd]
        [<ffffffffa02e54e8>] ? usb_audio_disconnect+0x88/0x1c0 [snd_usb_audio]
        [<ffffffffa015260e>] ? usb_unbind_interface+0x5e/0x1b0 [usbcore]
        [<ffffffff813553e9>] ? __device_release_driver+0x79/0xf0
        [<ffffffff81355485>] ? device_release_driver+0x25/0x40
        [<ffffffff81354e11>] ? bus_remove_device+0xf1/0x130
        [<ffffffff813522b9>] ? device_del+0x109/0x180
        [<ffffffffa01501d5>] ? usb_disable_device+0x95/0x1f0 [usbcore]
        [<ffffffffa014634f>] ? usb_disconnect+0x8f/0x190 [usbcore]
        [<ffffffffa0149179>] ? hub_thread+0x539/0x13a0 [usbcore]
        [<ffffffff810669f5>] ? sched_clock_local+0x15/0x80
        [<ffffffff81066c98>] ? sched_clock_cpu+0xb8/0xd0
        [<ffffffff81070730>] ? bit_waitqueue+0xb0/0xb0
        [<ffffffffa0148c40>] ? usb_port_resume+0x430/0x430 [usbcore]
        [<ffffffffa0148c40>] ? usb_port_resume+0x430/0x430 [usbcore]
        [<ffffffff8105973e>] ? kthread+0xce/0xf0
        [<ffffffff81059670>] ? kthread_create_on_node+0x1c0/0x1c0
        [<ffffffff814a8b7c>] ? ret_from_fork+0x7c/0xb0
        [<ffffffff81059670>] ? kthread_create_on_node+0x1c0/0x1c0
       ---[ end trace 40b1928d1136b91e ]---
      
      This comes from the fact that usb-audio driver may receive the
      disconnect callback multiple times, per each usb interface.  When a
      device has both audio and midi interfaces, it gets called twice, and
      currently the driver tries to release resources at the last call.
      At this point, the first parent interface has been already deleted,
      thus deleting a child of the first parent hits such a warning.
      
      For fixing this problem, we need to call snd_card_disconnect() and
      cancel pending operations at the very first disconnect while the
      release of the whole objects waits until the last disconnect call.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=80931Reported-and-tested-by: default avatarTomas Gayoso <tgayoso@gmail.com>
      Reported-and-tested-by: default avatarChris J Arges <chris.j.arges@canonical.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      2dbb38ff
    • Adel Gadllah's avatar
      HID: usbhid: enable always-poll quirk for Elan Touchscreen 016f · 07c1ac29
      Adel Gadllah authored
      commit 1af39588 upstream.
      
      This device needs the quirk as well.
      Tested-by: default avatarKevin Fenzi <kevin@scrye.com>
      Signed-off-by: default avatarAdel Gadllah <adel.gadllah@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      07c1ac29
    • Adel Gadllah's avatar
      HID: usbhid: enable always-poll quirk for Elan Touchscreen 009b · 51925e17
      Adel Gadllah authored
      commit 29d05c2e upstream.
      
      This device needs the quirk as well.
      Signed-off-by: default avatarAdel Gadllah <adel.gadllah@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      51925e17
    • Johan Hovold's avatar
      HID: usbhid: enable always-poll quirk for Elan Touchscreen · 12127f7f
      Johan Hovold authored
      commit bfe3c873 upstream.
      
      Enable the always-poll quirk for Elan Touchscreens found on some recent
      Samsung laptops.
      
      Without this quirk the device keeps disconnecting from the bus (and is
      re-enumerated) unless opened (and kept open, should an input event
      occur).
      
      Note that while the device can be run-time suspended, the autosuspend
      timeout must be high enough to allow the device to be polled at least
      once before being suspended. Specifically, using autosuspend_delay_ms=0
      will still cause the device to disconnect on input events.
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      12127f7f
    • Johan Hovold's avatar
      HID: usbhid: add always-poll quirk · 972b69a5
      Johan Hovold authored
      commit 0b750b3b upstream.
      
      Add quirk to make sure that a device is always polled for input events
      even if it hasn't been opened.
      
      This is needed for devices that disconnects from the bus unless the
      interrupt endpoint has been polled at least once or when not responding
      to an input event (e.g. after having shut down X).
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      972b69a5
    • Adel Gadllah's avatar
      USB: quirks: enable device-qualifier quirk for yet another Elan touchscreen · 605e3548
      Adel Gadllah authored
      commit d7499475 upstream.
      
      Yet another device affected by this.
      Tested-by: default avatarKevin Fenzi <kevin@scrye.com>
      Signed-off-by: default avatarAdel Gadllah <adel.gadllah@gmail.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      605e3548
    • Adel Gadllah's avatar
      USB: quirks: enable device-qualifier quirk for another Elan touchscreen · 21748d8c
      Adel Gadllah authored
      commit 876af5d4 upstream.
      
      Currently this quirk is enabled for the model with the device id 0x0089, it
      is needed for the 0x009b model, which is found on the Fujitsu Lifebook u904
      as well.
      Signed-off-by: default avatarAdel Gadllah <adel.gadllah@gmail.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      21748d8c
    • Johan Hovold's avatar
      USB: quirks: enable device-qualifier quirk for Elan Touchscreen · 08972217
      Johan Hovold authored
      commit c68929f7 upstream.
      
      Enable device-qualifier quirk for Elan Touchscreen, which often fails to
      handle requests for the device_descriptor.
      
      Note that the device sometimes do respond properly with a Request Error
      (three times as USB core retries), but usually fails to respond at all.
      When this happens any further descriptor requests also fails, for
      example:
      
      [ 1528.688934] usb 2-7: new full-speed USB device number 4 using xhci_hcd
      [ 1530.945588] usb 2-7: unable to read config index 0 descriptor/start: -71
      [ 1530.945592] usb 2-7: can't read configurations, error -71
      
      This has been observed repeating for over a minute before eventual
      successful enumeration.
      Reported-by: default avatarDrew Von Spreecken <drewvs@gmail.com>
      Reported-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      08972217
    • Johan Hovold's avatar
      USB: core: add device-qualifier quirk · 856cb361
      Johan Hovold authored
      commit 2a159389 upstream.
      
      Add new quirk for devices that cannot handle requests for the
      device_qualifier descriptor.
      
      A USB-2.0 compliant device must respond to requests for the
      device_qualifier descriptor (even if it's with a request error), but at
      least one device is known to misbehave after such a request.
      Suggested-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      856cb361
    • Thomas Gleixner's avatar
      usb: musb: cppi41: restart hrtimer only if not yet done · cd4386a9
      Thomas Gleixner authored
      commit d2e6d62c upstream.
      
      commit c58d80f5 ("usb: musb: Ensure that cppi41 timer gets armed on
      premature DMA TX irq") fixed hrtimer scheduling bug. There is one left
      which does not trigger that often.
      The following scenario is still possible:
      
          lock(&x->lock);
          hrtimer_start(&x->t);
          unlock(&x->lock);
      
      expires:
          t->function();
                                      lock(&x->lock);
          lock(&x->lock);             if (!hrtimer_queued(&x->t))
                                              hrtimer_start(&x->t);
                                      unlock(&x->lock);
      
          if (!list_empty(x->early_tx_list))
                 ret = HRTIMER_RESTART;
      ->         hrtimer_forward_now(...)
          } else
                 ret = HRTIMER_NORESTART;
      
          unlock(&x->lock);
      
      and the timer callback returns HRTIMER_RESTART for an armed timer. This
      is wrong and we run into the BUG_ON() in __run_hrtimer().
      This can happens on SMP or PREEMPT-RT.
      The patch fixes the problem by only starting the timer if the timer is
      not yet queued.
      Reported-by: default avatarTorben Hohn <torbenh@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      [bigeasy: collected information and created a patch + description based
                on it]
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      cd4386a9
    • Dmitry Eremin-Solenikov's avatar
      spi: pxa2xx: toggle clocks on suspend if not disabled by runtime PM · 45b5df58
      Dmitry Eremin-Solenikov authored
      commit 2b9375b9 upstream.
      
      If PM_RUNTIME is enabled, it is easy to trigger the following backtrace
      on pxa2xx hosts:
      
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 1 at /home/lumag/linux/arch/arm/mach-pxa/clock.c:35 clk_disable+0xa0/0xa8()
      Modules linked in:
      CPU: 0 PID: 1 Comm: swapper Not tainted 3.17.0-00007-g1b3d2ee-dirty #104
      [<c000de68>] (unwind_backtrace) from [<c000c078>] (show_stack+0x10/0x14)
      [<c000c078>] (show_stack) from [<c001d75c>] (warn_slowpath_common+0x6c/0x8c)
      [<c001d75c>] (warn_slowpath_common) from [<c001d818>] (warn_slowpath_null+0x1c/0x24)
      [<c001d818>] (warn_slowpath_null) from [<c0015e80>] (clk_disable+0xa0/0xa8)
      [<c0015e80>] (clk_disable) from [<c02507f8>] (pxa2xx_spi_suspend+0x2c/0x34)
      [<c02507f8>] (pxa2xx_spi_suspend) from [<c0200360>] (platform_pm_suspend+0x2c/0x54)
      [<c0200360>] (platform_pm_suspend) from [<c0207fec>] (dpm_run_callback.isra.14+0x2c/0x74)
      [<c0207fec>] (dpm_run_callback.isra.14) from [<c0209254>] (__device_suspend+0x120/0x2f8)
      [<c0209254>] (__device_suspend) from [<c0209a94>] (dpm_suspend+0x50/0x208)
      [<c0209a94>] (dpm_suspend) from [<c00455ac>] (suspend_devices_and_enter+0x8c/0x3a0)
      [<c00455ac>] (suspend_devices_and_enter) from [<c0045ad4>] (pm_suspend+0x214/0x2a8)
      [<c0045ad4>] (pm_suspend) from [<c04b5c34>] (test_suspend+0x14c/0x1dc)
      [<c04b5c34>] (test_suspend) from [<c000880c>] (do_one_initcall+0x8c/0x1fc)
      [<c000880c>] (do_one_initcall) from [<c04aecfc>] (kernel_init_freeable+0xf4/0x1b4)
      [<c04aecfc>] (kernel_init_freeable) from [<c0378078>] (kernel_init+0x8/0xec)
      [<c0378078>] (kernel_init) from [<c0009590>] (ret_from_fork+0x14/0x24)
      ---[ end trace 46524156d8faa4f6 ]---
      
      This happens because suspend function tries to disable a clock that is
      already disabled by runtime_suspend callback. Add if
      (!pm_runtime_suspended()) checks to suspend/resume path.
      
      Fixes: 7d94a505 (spi/pxa2xx: add support for runtime PM)
      Signed-off-by: default avatarDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
      Reported-by: default avatarAndrea Adami <andrea.adami@gmail.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      45b5df58
    • Alexander Stein's avatar
      spi: fsl-dspi: Fix CTAR selection · 35a3997b
      Alexander Stein authored
      commit 5cc7b047 upstream.
      
      There are only 4 CTAR registers (CTAR0 - CTAR3) so we can only use the
      lower 2 bits of the chip select to select a CTAR register.
      SPI_PUSHR_CTAS used the lower 3 bits which would result in wrong bit values
      if the chip selects 4/5 are used. For those chip selects SPI_CTAR even
      calculated offsets of non-existing registers.
      Signed-off-by: default avatarAlexander Stein <alexander.stein@systec-electronic.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      35a3997b
    • Ray Jui's avatar
      spi: pl022: Fix incorrect dma_unmap_sg · d0ef4acc
      Ray Jui authored
      commit 3ffa6158 upstream.
      
      When mapped RX DMA entries are unmapped in an error condition when DMA
      is firstly configured in the driver, the number of TX DMA entries was
      passed in, which is incorrect
      Signed-off-by: default avatarRay Jui <rjui@broadcom.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      d0ef4acc
    • Jack Pham's avatar
      usb: dwc3: gadget: Properly initialize LINK TRB · 37529c72
      Jack Pham authored
      commit 1200a82a upstream.
      
      On ISOC endpoints the last trb_pool entry used as a
      LINK TRB is not getting zeroed out correctly due to
      memset being called incorrectly and in the wrong place.
      If pool allocated from DMA was not zero-initialized
      to begin with this will result in the size and ctrl
      values being random garbage. Call memset correctly after
      assignment of the trb_link pointer.
      
      Fixes: f6bafc6a ("usb: dwc3: convert TRBs into bitshifts")
      Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      37529c72