1. 28 1月, 2016 1 次提交
  2. 24 7月, 2015 1 次提交
  3. 25 5月, 2015 1 次提交
  4. 11 5月, 2015 1 次提交
    • P
      tty/n_gsm.c: fix a memory leak when gsmtty is removed · 8f9cfeed
      Pan Xinhui 提交于
      when gsmtty_remove put dlci, it will cause memory leak if dlci->port's refcount is zero.
      So we do the cleanup work in .cleanup callback instead.
      
      dlci will be last put in two call chains.
      1) gsmld_close -> gsm_cleanup_mux -> gsm_dlci_release -> dlci_put
      2) gsmld_remove -> dlci_put
      so there is a race. the memory leak depends on the race.
      
      In call chain 2. we hit the memory leak. below comment tells.
      
      release_tty -> tty_driver_remove_tty -> gsmtty_remove -> dlci_put -> tty_port_destructor (WARN_ON(port->itty) and return directly)
                               |
                      tty->port->itty = NULL;
                               |
                      tty_kref_put ---> release_one_tty -> gsmtty_cleanup (added by our patch)
      
      So our patch fix the memory leak by doing the cleanup work after tty core did.
      Signed-off-by: NPan Xinhui <xinhuix.pan@intel.com>
      Fixes: dfabf7ff
      Cc: stable <stable@vger.kernel.org> # 3.14+
      Acked-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8f9cfeed
  5. 07 5月, 2015 1 次提交
  6. 10 4月, 2015 1 次提交
  7. 26 3月, 2015 1 次提交
  8. 02 8月, 2014 2 次提交
  9. 24 7月, 2014 1 次提交
  10. 16 7月, 2014 1 次提交
    • T
      net: set name_assign_type in alloc_netdev() · c835a677
      Tom Gundersen 提交于
      Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert
      all users to pass NET_NAME_UNKNOWN.
      
      Coccinelle patch:
      
      @@
      expression sizeof_priv, name, setup, txqs, rxqs, count;
      @@
      
      (
      -alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
      +alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs)
      |
      -alloc_netdev_mq(sizeof_priv, name, setup, count)
      +alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count)
      |
      -alloc_netdev(sizeof_priv, name, setup)
      +alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup)
      )
      
      v9: move comments here from the wrong commit
      Signed-off-by: NTom Gundersen <teg@jklm.no>
      Reviewed-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c835a677
  11. 08 2月, 2014 1 次提交
    • L
      tty: n_gsm: Fix for modems with brk in modem status control · 3ac06b90
      Lars Poeschel 提交于
      3GPP TS 07.10 states in section 5.4.6.3.7:
      "The length byte contains the value 2 or 3 ... depending on the break
      signal." The break byte is optional and if it is sent, the length is
      3. In fact the driver was not able to work with modems that send this
      break byte in their modem status control message. If the modem just
      sends the break byte if it is really set, then weird things might
      happen.
      The code for deconding the modem status to the internal linux
      presentation in gsm_process_modem has already a big comment about
      this 2 or 3 byte length thing and it is already able to decode the
      brk, but the code calling the gsm_process_modem function in
      gsm_control_modem does not encode it and hand it over the right way.
      This patch fixes this.
      Without this fix if the modem sends the brk byte in it's modem status
      control message the driver will hang when opening a muxed channel.
      Signed-off-by: NLars Poeschel <poeschel@lemonage.de>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3ac06b90
  12. 19 12月, 2013 1 次提交
    • C
      TTY/n_gsm: Removing the wrong tty_unlock/lock() in gsm_dlci_release() · be706572
      Chuansheng Liu 提交于
      Commit 4d9b1090(tty: Prevent deadlock in n_gsm driver)
      tried to close all the virtual ports synchronously before closing the
      phycial ports, so the tty_vhangup() is used.
      
      But the tty_unlock/lock() is wrong:
      tty_release
       tty_ldisc_release
        tty_lock_pair(tty, o_tty)  < == Here the tty is for physical port
        tty_ldisc_kill
          gsmld_close
            gsm_cleanup_mux
              gsm_dlci_release
                tty = tty_port_tty_get(&dlci->port)
                                  < == Here the tty(s) are for virtual port
      
      They are different ttys, so before tty_vhangup(virtual tty), do not need
      to call the tty_unlock(virtual tty) at all which causes unbalanced unlock
      warning.
      
      When enabling mutex debugging option, we will hit the below warning also:
      [   99.276903] =====================================
      [   99.282172] [ BUG: bad unlock balance detected! ]
      [   99.287442] 3.10.20-261976-gaec5ba0 #44 Tainted: G           O
      [   99.293972] -------------------------------------
      [   99.299240] mmgr/152 is trying to release lock (&tty->legacy_mutex) at:
      [   99.306693] [<c1b2dcad>] mutex_unlock+0xd/0x10
      [   99.311669] but there are no more locks to release!
      [   99.317131]
      [   99.317131] other info that might help us debug this:
      [   99.324440] 3 locks held by mmgr/152:
      [   99.328542]  #0:  (&tty->legacy_mutex/1){......}, at: [<c1b30ab0>] tty_lock_nested+0x40/0x90
      [   99.338116]  #1:  (&tty->ldisc_mutex){......}, at: [<c15dbd02>] tty_ldisc_kill+0x22/0xd0
      [   99.347284]  #2:  (&gsm->mutex){......}, at: [<c15e3d83>] gsm_cleanup_mux+0x73/0x170
      [   99.356060]
      [   99.356060] stack backtrace:
      [   99.360932] CPU: 0 PID: 152 Comm: mmgr Tainted: G           O 3.10.20-261976-gaec5ba0 #44
      [   99.370086]  ef4a4de0 ef4a4de0 ef4c1d98 c1b27b91 ef4c1db8 c1292655 c1dd10f5 c1b2dcad
      [   99.378921]  c1b2dcad ef4a4de0 ef4a528c ffffffff ef4c1dfc c12930dd 00000246 00000000
      [   99.387754]  00000000 00000000 c15e1926 00000000 00000001 ddfa7530 00000003 c1b2dcad
      [   99.396588] Call Trace:
      [   99.399326]  [<c1b27b91>] dump_stack+0x16/0x18
      [   99.404307]  [<c1292655>] print_unlock_imbalance_bug+0xe5/0xf0
      [   99.410840]  [<c1b2dcad>] ? mutex_unlock+0xd/0x10
      [   99.416110]  [<c1b2dcad>] ? mutex_unlock+0xd/0x10
      [   99.421382]  [<c12930dd>] lock_release_non_nested+0x1cd/0x210
      [   99.427818]  [<c15e1926>] ? gsm_destroy_network+0x36/0x130
      [   99.433964]  [<c1b2dcad>] ? mutex_unlock+0xd/0x10
      [   99.439235]  [<c12931a2>] lock_release+0x82/0x1c0
      [   99.444505]  [<c1b2dcad>] ? mutex_unlock+0xd/0x10
      [   99.449776]  [<c1b2dcad>] ? mutex_unlock+0xd/0x10
      [   99.455047]  [<c1b2dc2f>] __mutex_unlock_slowpath+0x5f/0xd0
      [   99.461288]  [<c1b2dcad>] mutex_unlock+0xd/0x10
      [   99.466365]  [<c1b30bb1>] tty_unlock+0x21/0x50
      [   99.471345]  [<c15e3dd1>] gsm_cleanup_mux+0xc1/0x170
      [   99.476906]  [<c15e44d2>] gsmld_close+0x52/0x90
      [   99.481983]  [<c15db905>] tty_ldisc_close.isra.1+0x35/0x50
      [   99.488127]  [<c15dbd0c>] tty_ldisc_kill+0x2c/0xd0
      [   99.493494]  [<c15dc7af>] tty_ldisc_release+0x2f/0x50
      [   99.499152]  [<c15d572c>] tty_release+0x37c/0x4b0
      [   99.504424]  [<c1b2dcad>] ? mutex_unlock+0xd/0x10
      [   99.509695]  [<c1b2dcad>] ? mutex_unlock+0xd/0x10
      [   99.514967]  [<c1372f6e>] ? eventpoll_release_file+0x7e/0x90
      [   99.521307]  [<c1335849>] __fput+0xd9/0x200
      [   99.525996]  [<c133597d>] ____fput+0xd/0x10
      [   99.530685]  [<c125c731>] task_work_run+0x81/0xb0
      [   99.535957]  [<c12019e9>] do_notify_resume+0x49/0x70
      [   99.541520]  [<c1b30dc4>] work_notifysig+0x29/0x31
      [   99.546897] ------------[ cut here ]------------
      
      So here we can call tty_vhangup() directly which is for virtual port.
      Reviewed-by: NChao Bi <chao.bi@intel.com>
      Signed-off-by: NLiu, Chuansheng <chuansheng.liu@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be706572
  13. 18 12月, 2013 1 次提交
    • R
      drivers: tty: Mark the functions as static in n_gsm.c · 54af5836
      Rashika Kheria 提交于
      Marks the functions gsm_cleanup_mux(), gsm_activate_mux(),
      gsm_free_mux(), gsm_alloc_mux() and gsm_change_mtu() as static in
      n_gsm.c because they are not used outside this file.
      
      Also, drop the EXPORT_SYMBOL_GPL for the above mentioned functions
      because nothing else in the kernel calls them.
      
      This eliminates the following warnings in n_gsm.c:
      drivers/tty/n_gsm.c:2022:6: warning: no previous prototype for ‘gsm_cleanup_mux’ [-Wmissing-prototypes]
      drivers/tty/n_gsm.c:2076:5: warning: no previous prototype for ‘gsm_activate_mux’ [-Wmissing-prototypes]
      drivers/tty/n_gsm.c:2120:6: warning: no previous prototype for ‘gsm_free_mux’ [-Wmissing-prototypes]
      drivers/tty/n_gsm.c:2156:17: warning: no previous prototype for ‘gsm_alloc_mux’ [-Wmissing-prototypes]
      drivers/tty/n_gsm.c:2714:5: warning: no previous prototype for ‘gsm_change_mtu’ [-Wmissing-prototypes]
      Signed-off-by: NRashika Kheria <rashika.kheria@gmail.com>
      Reviewed-by: NJosh Triplett <josh@joshtriplett.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      54af5836
  14. 09 12月, 2013 2 次提交
    • C
      n_gsm: race between ld close and gsmtty open · dfabf7ff
      Chao Bi 提交于
      ttyA has ld associated to n_gsm, when ttyA is closing, it triggers
      to release gsmttyB's ld data dlci[B], then race would happen if gsmttyB
      is opening in parallel.
      
      (Note: This patch set differs from previous set in that it uses mutex
      instead of spin lock to avoid race, so that it avoids sleeping in automic
      context)
      
      Here are race cases we found recently in test:
      
      CASE #1
      ====================================================================
      releasing dlci[B] race with gsmtty_install(gsmttyB), then panic
      in gsmtty_open(gsmttyB), as below:
      
       tty_release(ttyA)                  tty_open(gsmttyB)
           |                                   |
         -----                           gsmtty_install(gsmttyB)
           |                                   |
         -----                    gsm_dlci_alloc(gsmttyB) => alloc dlci[B]
       tty_ldisc_release(ttyA)               -----
           |                                   |
       gsm_dlci_release(dlci[B])             -----
           |                                   |
       gsm_dlci_free(dlci[B])                -----
           |                                   |
         -----                           gsmtty_open(gsmttyB)
      
       gsmtty_open()
       {
           struct gsm_dlci *dlci = tty->driver_data; => here it uses dlci[B]
           ...
       }
      
       In gsmtty_open(gsmttyA), it uses dlci[B] which was release, so hit a panic.
      =====================================================================
      
      CASE #2
      =====================================================================
      releasing dlci[0] race with gsmtty_install(gsmttyB), then panic
      in gsmtty_open(), as below:
      
       tty_release(ttyA)                  tty_open(gsmttyB)
           |                                   |
         -----                           gsmtty_install(gsmttyB)
           |                                   |
         -----                    gsm_dlci_alloc(gsmttyB) => alloc dlci[B]
           |                                   |
         -----                         gsmtty_open(gsmttyB) fail
           |                                   |
         -----                           tty_release(gsmttyB)
           |                                   |
         -----                           gsmtty_close(gsmttyB)
           |                                   |
         -----                        gsmtty_detach_dlci(dlci[B])
           |                                   |
         -----                             dlci_put(dlci[B])
           |                                   |
       tty_ldisc_release(ttyA)               -----
           |                                   |
       gsm_dlci_release(dlci[0])             -----
           |                                   |
       gsm_dlci_free(dlci[0])                -----
           |                                   |
         -----                             dlci_put(dlci[0])
      
       In gsmtty_detach_dlci(dlci[B]), it tries to use dlci[0] which was released,
       then hit panic.
      =====================================================================
      
      IMHO, n_gsm tty operations would refer released ldisc,  as long as
      gsm_dlci_release() has chance to release ldisc data when some gsmtty operations
      are ongoing..
      
      This patch is try to avoid it by:
      
      1) in n_gsm driver, use a global gsm mutex lock to avoid gsm_dlci_release() run in
      parallel with gsmtty_install();
      
      2) Increase dlci's ref count in gsmtty_install() instead of in gsmtty_open(), the
      purpose is to prevent gsm_dlci_release() releasing dlci after gsmtty_install()
      allocats dlci but before gsmtty_open increases dlci's ref count;
      
      3) Decrease dlci's ref count in gsmtty_remove(), a tty framework API, this is the
      opposite process of step 2).
      Signed-off-by: NChao Bi <chao.bi@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dfabf7ff
    • P
      tty: Always handle NULL flag ptr · 82f91fe0
      Peter Hurley 提交于
      Most line disciplines already handle the undocumented NULL flag
      ptr in their .receive_buf method; however, several don't.
      
      Document the NULL flag ptr, and correct handling in the
      N_MOUSE, N_GSM0710 and N_R394 line disciplines.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Acked-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82f91fe0
  15. 26 11月, 2013 2 次提交
    • G
      Revert "n_gsm: race between ld close and gsmtty open" · c42b4e65
      Greg Kroah-Hartman 提交于
      This reverts commit c284ee2c.  Turns out
      the locking was incorrect.
      Reported-by: NFengguang Wu <fengguang.wu@intel.com>
      Cc: Chao Bi <chao.bi@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c42b4e65
    • C
      n_gsm: race between ld close and gsmtty open · c284ee2c
      Chao Bi 提交于
      ttyA has ld associated to n_gsm, when ttyA is closing, it triggers
      to release gsmttyB's ld data dlci[B], then race would happen if gsmttyB
      is opening in parallel.
      
      Here are race cases we found recently in test:
      
      CASE #1
      ====================================================================
      releasing dlci[B] race with gsmtty_install(gsmttyB), then panic
      in gsmtty_open(gsmttyB), as below:
      
       tty_release(ttyA)                  tty_open(gsmttyB)
           |                                   |
         -----                           gsmtty_install(gsmttyB)
           |                                   |
         -----                    gsm_dlci_alloc(gsmttyB) => alloc dlci[B]
       tty_ldisc_release(ttyA)               -----
           |                                   |
       gsm_dlci_release(dlci[B])             -----
           |                                   |
       gsm_dlci_free(dlci[B])                -----
           |                                   |
         -----                           gsmtty_open(gsmttyB)
      
       gsmtty_open()
       {
           struct gsm_dlci *dlci = tty->driver_data; => here it uses dlci[B]
           ...
       }
      
       In gsmtty_open(gsmttyA), it uses dlci[B] which was release, so hit a panic.
      =====================================================================
      
      CASE #2
      =====================================================================
      releasing dlci[0] race with gsmtty_install(gsmttyB), then panic
      in gsmtty_open(), as below:
      
       tty_release(ttyA)                  tty_open(gsmttyB)
           |                                   |
         -----                           gsmtty_install(gsmttyB)
           |                                   |
         -----                    gsm_dlci_alloc(gsmttyB) => alloc dlci[B]
           |                                   |
         -----                         gsmtty_open(gsmttyB) fail
           |                                   |
         -----                           tty_release(gsmttyB)
           |                                   |
         -----                           gsmtty_close(gsmttyB)
           |                                   |
         -----                        gsmtty_detach_dlci(dlci[B])
           |                                   |
         -----                             dlci_put(dlci[B])
           |                                   |
       tty_ldisc_release(ttyA)               -----
           |                                   |
       gsm_dlci_release(dlci[0])             -----
           |                                   |
       gsm_dlci_free(dlci[0])                -----
           |                                   |
         -----                             dlci_put(dlci[0])
      
       In gsmtty_detach_dlci(dlci[B]), it tries to use dlci[0] which was released,
       then hit panic.
      =====================================================================
      
      IMHO, n_gsm tty operations would refer released ldisc,  as long as
      gsm_dlci_release() has chance to release ldisc data when some gsmtty operations
      are not completed..
      
      This patch is try to avoid it by:
      
      1) in n_gsm driver, use a global gsm spin lock to avoid gsm_dlci_release() run in
      parallel with gsmtty_install();
      
      2) Increase dlci's ref count in gsmtty_install() instead of in gsmtty_open(), the
      purpose is to prevent gsm_dlci_release() releasing dlci after gsmtty_install()
      allocats dlci but before gsmtty_open increases dlci's ref count;
      
      3) Decrease dlci's ref count in gsmtty_remove(), which is a tty framework api, and
      this is the opposite process of step 2).
      Signed-off-by: NChao Bi <chao.bi@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c284ee2c
  16. 25 7月, 2013 1 次提交
    • A
      Drivers: tty: n_gsm.c: fixed 7 errors & 6 warnings that checkpatch complained · f3c909b4
      Aldo Iljazi 提交于
      Specifically:
      n_gsm.c:810: ERROR: space required before the open parenthesis '('
      n_gsm.c:830: WARNING: line over 80 characters
      n_gsm.c:971: ERROR: trailing whitespace
      n_gsm.c:984: ERROR: code indent should use tabs where possible
      n_gsm.c:984: WARNING: please, no space before tabs
      n_gsm.c:984: WARNING: please, no spaces at the start of a line
      n_gsm.c:1141: WARNING: space prohibited before semicolon
      n_gsm.c:1743: ERROR: space required before the open brace '{'
      n_gsm.c:1744: WARNING: line over 80 characters
      n_gsm.c:1745: ERROR: code indent should use tabs where possible
      n_gsm.c:1746: ERROR: code indent should use tabs where possible
      n_gsm.c:2908: WARNING: line over 80 characters
      n_gsm.c:2912: ERROR: trailing whitespace
      Signed-off-by: NAldo Iljazi <neonsync1@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f3c909b4
  17. 19 3月, 2013 2 次提交
    • J
      TTY: fix DTR not being dropped on hang up · 957dacae
      Johan Hovold 提交于
      Move HUPCL handling to port shutdown so that DTR is dropped also on hang
      up (tty_port_close is a noop for hung-up ports).
      
      Also do not try to drop DTR for uninitialised ports where it has never
      been raised (e.g. after a failed open).
      
      Note that this is also the current behaviour of serial-core.
      
      Nine drivers currently call tty_port_close_start directly (rather than
      through tty_port_close) and seven of them lower DTR as part of their
      close (if the port has been initialised). Fixup the remaining two
      drivers so that it continues to be lowered also on normal (non-HUP)
      close. [ Note that most of those other seven drivers did not expect DTR
      to have been dropped by tty_port_close_start in the first place. ]
      Signed-off-by: NJohan Hovold <jhovold@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      957dacae
    • J
      TTY: add tty_port_tty_hangup helper · aa27a094
      Jiri Slaby 提交于
      It allows for cleaning up on a considerable amount of places. They did
      port_get, hangup, kref_put. Now the only thing needed is to call
      tty_port_tty_hangup which does exactly that. And they can also decide
      whether to consider CLOCAL or completely ignore that.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aa27a094
  18. 30 1月, 2013 1 次提交
    • D
      tty: Prevent deadlock in n_gsm driver · 4d9b1090
      Dirkjan Bussink 提交于
      This change fixes a deadlock when the multiplexer is closed while there
      are still client side ports open.
      
      When the multiplexer is closed and there are active tty's it tries to
      close them with tty_vhangup. This has a problem though, because
      tty_vhangup needs the tty_lock. This patch changes it to unlock the
      tty_lock before attempting the hangup and relocks afterwards. The
      additional call to tty_port_tty_set is needed because otherwise the
      port stays active because of the reference counter.
      
      This change also exposed another problem that other code paths don't
      expect that the multiplexer could have been closed. This patch also adds
      checks for these cases in the gsmtty_ class of function that could be
      called.
      
      The documentation explicitly states that "first close all virtual ports
      before closing the physical port" but we've found this to not always
      reality in our field situations. The GPRS / UTMS modem sometimes crashes
      and needs a power cycle in that case which means cleanly shutting down
      everything is not always possible. This change makes it much more robust
      for our situation where at least the system is recoverable with this patch
      and doesn't hang in a deadlock situation inside the kernel.
      
      The patch is against the long term support kernel (3.4.27) and should
      apply cleanly to more recent branches. Tested with a Telit GE864-QUADV2
      and Telit HE910 modem.
      Signed-off-by: NDirkjan Bussink <dirkjan.bussink@nedap.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d9b1090
  19. 16 1月, 2013 5 次提交
  20. 16 11月, 2012 1 次提交
  21. 17 9月, 2012 1 次提交
  22. 17 8月, 2012 8 次提交
  23. 11 8月, 2012 1 次提交
  24. 17 7月, 2012 1 次提交
  25. 09 3月, 2012 1 次提交