1. 30 10月, 2015 5 次提交
  2. 28 10月, 2015 4 次提交
    • R
      NFC: nci: non-static functions can not be inline · f1163174
      Robert Dolca 提交于
      This fixes a build error that seems to be toochain
      dependent (Not seen with gcc v5.1):
      
      In file included from net/nfc/nci/rsp.c:36:0:
      net/nfc/nci/rsp.c: In function ‘nci_rsp_packet’:
      include/net/nfc/nci_core.h:355:12: error: inlining failed in call to
      always_inline ‘nci_prop_rsp_packet’: function body not available
       inline int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 opcode,
      Signed-off-by: NRobert Dolca <robert.dolca@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      f1163174
    • R
      mpls: reduce memory usage of routes · cf4b24f0
      Robert Shearman 提交于
      Nexthops for MPLS routes have a via address field sized for the
      largest via address that is expected, which is 32 bytes. This means
      that in the most common case of having ipv4 via addresses, 28 bytes of
      memory more than required are used per nexthop. In the other common
      case of an ipv6 nexthop then 16 bytes more than required are
      used. With large numbers of MPLS routes this extra memory usage could
      start to become significant.
      
      To avoid allocating memory for a maximum length via address when not
      all of it is required and to allow for ease of iterating over
      nexthops, then the via addresses are changed to be stored in the same
      memory block as the route and nexthops, but in an array after the end
      of the array of nexthops. New accessors are provided to retrieve a
      pointer to the via address.
      
      To allow for O(1) access without having to store a pointer or offset
      per nh, the via address for each nexthop is sized according to the
      maximum via address for any nexthop in the route, which is stored in a
      new route field, rt_max_alen, but this is in an existing hole in
      struct mpls_route so it doesn't increase the size of the
      structure. Each via address is ensured to be aligned to VIA_ALEN_ALIGN
      to account for architectures that don't allow unaligned accesses.
      Signed-off-by: NRobert Shearman <rshearma@brocade.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cf4b24f0
    • R
      mpls: fix forwarding using v4/v6 explicit null · b4e04fc7
      Robert Shearman 提交于
      Fill in the via address length for the predefined IPv4 and IPv6
      explicit-null label routes.
      
      Fixes: f8efb73c ("mpls: multipath route support")
      Signed-off-by: NRobert Shearman <rshearma@brocade.com>
      Acked-by: NRoopa Prabhu <roopa@cumulusnetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b4e04fc7
    • H
      sock: don't enable netstamp for af_unix sockets · 080a270f
      Hannes Frederic Sowa 提交于
      netstamp_needed is toggled for all socket families if they request
      timestamping. But some protocols don't need the lower-layer timestamping
      code at all. This patch starts disabling it for af-unix.
      
      E.g. systemd enables timestamping during boot-up on the journald af-unix
      sockets, thus causing the system to globally enable timestamping in the
      lower networking stack. Still, it is very probable that timestamping
      gets activated, by e.g. dhclient or various NTP implementations.
      Reported-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Signed-off-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
      Acked-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      080a270f
  3. 27 10月, 2015 10 次提交
    • A
      bluetooth: 6lowpan: fix NOHZ: local_softirq_pending · 324e786e
      Alexander Aring 提交于
      Jukka reported about the following warning:
      
      "NOHZ: local_softirq_pending 08"
      
      I remember this warning and we had a similar issue when using workqueues
      and calling netif_rx. See commit 5ff3fec6 ("mac802154: fix NOHZ
      local_softirq_pending 08 warning").
      
      This warning occurs when calling "netif_rx" inside the wrong context
      (non softirq context). The net core api offers "netif_rx_ni" to call
      netif_rx inside the correct softirq context.
      Reported-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      324e786e
    • E
      net: tso: add support for IPv6 · 8941faa1
      emmanuel.grumbach@intel.com 提交于
      Adding IPv6 for the TSO helper API is trivial:
      * Don't play with the id (which doesn't exist in IPv6)
      * Correctly update the payload_len (don't include the
        length of the IP header itself)
      Signed-off-by: NEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Acked-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8941faa1
    • K
      Bluetooth: Fix crash on fast disconnect of SCO · 2c501cdd
      Kuba Pawlak 提交于
      Fix a crash that may happen when a connection is closed before it was fully
      established. Mapping conn->hcon was released by shutdown function, but it
      is still referenced in (not yet finished) connection established handling
      function.
      
      [ 4635.254073] BUG: unable to handle kernel NULL pointer dereference at 00000013
      [ 4635.262058] IP: [<c11659f0>] memcmp+0xe/0x25
      [ 4635.266835] *pdpt = 0000000024190001 *pde = 0000000000000000
      [ 4635.273261] Oops: 0000 [#1] PREEMPT SMP
      [ 4635.277652] Modules linked in: evdev ecb vfat fat libcomposite usb2380 isofs zlib_inflate rfcomm(O) udc_core bnep(O) btusb(O) btbcm(O) btintel(O) bluetooth(O) cdc_acm arc4 uinput hid_mule
      [ 4635.321761] Pid: 363, comm: kworker/u:2H Tainted: G           O 3.8.0-119.1-plk-adaptation-byt-ivi-brd #1
      [ 4635.332642] EIP: 0060:[<c11659f0>] EFLAGS: 00010206 CPU: 0
      [ 4635.338767] EIP is at memcmp+0xe/0x25
      [ 4635.342852] EAX: e4720678 EBX: 00000000 ECX: 00000006 EDX: 00000013
      [ 4635.349849] ESI: 00000000 EDI: fb85366c EBP: e40c7dc0 ESP: e40c7db4
      [ 4635.356846]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
      [ 4635.362873] CR0: 8005003b CR2: 00000013 CR3: 24191000 CR4: 001007f0
      [ 4635.369869] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      [ 4635.376865] DR6: ffff0ff0 DR7: 00000400
      [ 4635.381143] Process kworker/u:2H (pid: 363, ti=e40c6000 task=e40c5510 task.ti=e40c6000)
      [ 4635.390080] Stack:
      [ 4635.392319]  e4720400 00000000 fb85366c e40c7df4 fb842285 e40c7de2 fb853200 00000013
      [ 4635.401003]  e3f101c4 e4720678 e3f101c0 e403be0a e40c7dfc e416a000 e403be0a fb85366c
      [ 4635.409692]  e40c7e1c fb820186 020f6c00 e47c49ac e47c4008 00000000 e416a000 e47c402c
      [ 4635.418380] Call Trace:
      [ 4635.421153]  [<fb842285>] sco_connect_cfm+0xff/0x236 [bluetooth]
      [ 4635.427893]  [<fb820186>] hci_sync_conn_complete_evt.clone.101+0x227/0x268 [bluetooth]
      [ 4635.436758]  [<fb82370f>] hci_event_packet+0x1caa/0x21d3 [bluetooth]
      [ 4635.443859]  [<c106231f>] ? trace_hardirqs_on+0xb/0xd
      [ 4635.449502]  [<c1375b8a>] ? _raw_spin_unlock_irqrestore+0x42/0x59
      [ 4635.456340]  [<fb814b67>] hci_rx_work+0xb9/0x350 [bluetooth]
      [ 4635.462663]  [<c1039f1e>] ? process_one_work+0x17b/0x2e6
      [ 4635.468596]  [<c1039f77>] process_one_work+0x1d4/0x2e6
      [ 4635.474333]  [<c1039f1e>] ? process_one_work+0x17b/0x2e6
      [ 4635.480294]  [<fb814aae>] ? hci_cmd_work+0xda/0xda [bluetooth]
      [ 4635.486810]  [<c103a3fa>] worker_thread+0x171/0x20f
      [ 4635.492257]  [<c10456c5>] ? complete+0x34/0x3e
      [ 4635.497219]  [<c103ea06>] kthread+0x90/0x95
      [ 4635.501888]  [<c103a289>] ? manage_workers+0x1df/0x1df
      [ 4635.507628]  [<c1376537>] ret_from_kernel_thread+0x1b/0x28
      [ 4635.513755]  [<c103e976>] ? __init_kthread_worker+0x42/0x42
      [ 4635.519975] Code: 74 0d 3c 79 74 04 3c 59 75 0c c6 02 01 eb 03 c6 02 00 31 c0 eb 05 b8 ea ff ff ff 5d c3 55 89 e5 57 56 53 31 db eb 0e 0f b6 34 18 <0f> b6 3c 1a 43 29 fe 75 07 49 85 c9 7f
      [ 4635.541264] EIP: [<c11659f0>] memcmp+0xe/0x25 SS:ESP 0068:e40c7db4
      [ 4635.548166] CR2: 0000000000000013
      [ 4635.552177] ---[ end trace e05ce9b8ce6182f6 ]---
      Signed-off-by: NKuba Pawlak <kubax.t.pawlak@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      2c501cdd
    • B
      ipv6: icmp: include addresses in debug messages · 4b3418fb
      Bjørn Mork 提交于
      Messages like "icmp6_send: no reply to icmp error" are close
      to useless. Adding source and destination addresses to provide
      some more clue.
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4b3418fb
    • V
      NFC: NCI: allow spi driver to choose transfer clock · 2bd83245
      Vincent Cuissard 提交于
      In some cases low level drivers might want to update the
      SPI transfer clock (e.g. during firmware download).
      
      This patch adds this support. Without any modification the
      driver will use the default SPI clock (from pdata or device tree).
      Signed-off-by: NVincent Cuissard <cuissard@marvell.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      2bd83245
    • V
      NFC: NCI: move generic spi driver to a module · fcd9d046
      Vincent Cuissard 提交于
      SPI driver should be a module.
      Signed-off-by: NVincent Cuissard <cuissard@marvell.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      fcd9d046
    • V
      NFC: NCI: export nci_send_frame and nci_send_cmd function · e5629d29
      Vincent Cuissard 提交于
      Export nci_send_frame and nci_send_cmd symbols to allow drivers
      to use it. This is needed for example if NCI is used during
      firmware download phase.
      Signed-off-by: NVincent Cuissard <cuissard@marvell.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      e5629d29
    • C
      NFC: st21nfca: Add support for proprietary commands · 15d17170
      Christophe Ricard 提交于
      Add support for proprietary commands useful mainly
      for factory testings.
      
      Here is a list:
      
      - FACTORY_MODE: Allow to set the driver into a mode where no
        secure element are activated. It does not consider any
        NFC_ATTR_VENDOR_DATA.
      - HCI_CLEAR_ALL_PIPES: Allow to execute a HCI clear all pipes
        command. It does not consider any NFC_ATTR_VENDOR_DATA.
      - HCI_DM_PUT_DATA: Allow to configure specific CLF registry as
        for example RF trimmings or low level drivers configurations
        (I2C, SPI, SWP).
      - HCI_DM_UPDATE_AID: Allow to configure an AID routing into the
        CLF routing table following RF technology, CLF mode or protocol.
      - HCI_DM_GET_INFO: Allow to retrieve CLF information.
      - HCI_DM_GET_DATA: Allow to retrieve CLF configurable data such as
        low level drivers configurations or RF trimmings.
      - HCI_DM_LOAD: Allow to load a firmware into the CLF. A complete
        packet can be more than 8KB.
      - HCI_DM_RESET: Allow to run a CLF reset in order to "commit" CLF
        configuration changes without CLF power off.
      - HCI_GET_PARAM: Allow to retrieve an HCI CLF parameter (for example
        the white list).
      - HCI_DM_FIELD_GENERATOR: Allow to generate different kind of RF
        technology. When using this command to anti-collision is done.
      - HCI_LOOPBACK: Allow to echo a command and test the Dh to CLF
        connectivity.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      15d17170
    • C
      NFC: st-nci: Add few code style fixes · 064d0047
      Christophe Ricard 提交于
      Add some few code style fixes.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      064d0047
    • C
      NFC: netlink: Add mode parameter to deactivate_target functions · 96d4581f
      Christophe Ricard 提交于
      In order to manage in a better way the nci poll mode state machine,
      add mode parameter to deactivate_target functions.
      This way we can manage different target state.
      mode parameter make sense only in nci core.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      96d4581f
  4. 26 10月, 2015 21 次提交
    • M
      Bluetooth: Fix some obvious coding style issues in the SCO module · c4297e8f
      Marcel Holtmann 提交于
      Lets fix this obvious coding style issues in the SCO module and bring it
      in line with the rest of the Bluetooth subsystem.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      c4297e8f
    • M
      Bluetooth: Replace hci_notify with hci_sock_dev_event · 05fcd4c4
      Marcel Holtmann 提交于
      There is no point in wrapping hci_sock_dev_event around hci_notify. It
      is an empty wrapper which adds no value. So remove it.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      05fcd4c4
    • M
      Bluetooth: Rename bt_cb()->req into bt_cb()->hci · 242c0ebd
      Marcel Holtmann 提交于
      The SKB context buffer for HCI request is really not just for requests,
      information in their are preserved for the whole HCI layer. So it makes
      more sense to actually rename it into bt_cb()->hci and also call it then
      struct hci_ctrl.
      
      In addition that allows moving the decoded opcode for outgoing packets
      into that struct. So far it was just consuming valuable space from the
      main shared items. And opcode are not valid for L2CAP packets.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      242c0ebd
    • M
      Bluetooth: Remove unneeded parenthesis around MSG_OOB · d94a6104
      Marcel Holtmann 提交于
      There are two checks that are still using (MSG_OOB) instead of just
      MSG_OOB and so lets just fix them.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      d94a6104
    • C
      NFC: nci: Create pipe on specific gate in nci_hci_connect_gate · a1b0b941
      Christophe Ricard 提交于
      Some gates might need to have their pipes explicitly created.
      Add a call to nci_hci_create_pipe in nci_hci_connect_gate for
      every gate that is different than NCI_HCI_LINK_MGMT_GATE or
      NCI_HCI_ADMIN_GATE.
      
      In case of an error when opening a pipe, like in hci layer,
      delete the pipe if it was created.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      a1b0b941
    • C
      NFC: nci: Call nci_hci_clear_all_pipes at HCI initial activation. · 8a49943f
      Christophe Ricard 提交于
      When session_id is filled to 0xff, the pipe configuration is
      probably incorrect and needs to be cleared.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      8a49943f
    • C
      NFC: nci: add nci_hci_clear_all_pipes functions · fa6fbade
      Christophe Ricard 提交于
      nci_hci_clear_all_pipes might be use full in some cases
      for example after a firmware update.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      fa6fbade
    • C
      NFC: nci: extract pipe value using NCI_HCP_MSG_GET_PIPE · e65917b6
      Christophe Ricard 提交于
      When receiving data in nci_hci_msg_rx_work, extract pipe
      value using NCI_HCP_MSG_GET_PIPE macro.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      e65917b6
    • C
      NFC: nci: Fix improper management of HCI return code · d8cd37ed
      Christophe Ricard 提交于
      When sending HCI data over NCI, HCI return code is part
      of the NCI data. In order to get correctly the HCI return
      code, we assume the NCI communication is successful and
      extract the return code for the nci_hci functions return code.
      
      This is done because nci_to_errno does not match hci return
      code value.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      d8cd37ed
    • C
      NFC: nci: Fix incorrect data chaining when sending data · 500c4ef0
      Christophe Ricard 提交于
      When sending HCI data over NCI, cmd information should be
      present only on the first packet.
      Each packet shall be specifically allocated and sent to the
      NCI layer.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      500c4ef0
    • K
      Bluetooth: Fix locking issue during fast SCO reconnection. · 1da5537e
      Kuba Pawlak 提交于
      When SCO connection is requested and disconnected fast, there is a change
      that sco_sock_shutdown is going to preempt thread started in sco_connect_cfm.
      When this happens struct sock sk may be removed but a pointer to it is still
      held in sco_conn_ready, where embedded spinlock is used. If it is used, but
      struct sock has been removed, it will crash.
      
      Block connection object, which will prevent struct sock from being removed
      and give connection process chance to finish.
      
      BUG: spinlock bad magic on CPU#0, kworker/u:2H/319
       lock: 0xe3e99434, .magic: f3000000, .owner: (���/0, .owner_cpu: -203804160
      Pid: 319, comm: kworker/u:2H Tainted: G           O 3.8.0-115.1-plk-adaptation-byt-ivi-brd #1
      Call Trace:
       [<c1155659>] ? do_raw_spin_lock+0x19/0xe9
       [<fb75354f>] ? sco_connect_cfm+0x92/0x236 [bluetooth]
       [<fb731dbc>] ? hci_sync_conn_complete_evt.clone.101+0x18b/0x1cb [bluetooth]
       [<fb734ee7>] ? hci_event_packet+0x1acd/0x21a6 [bluetooth]
       [<c1041095>] ? finish_task_switch+0x50/0x89
       [<c1349a2e>] ? __schedule+0x638/0x6b8
       [<fb727918>] ? hci_rx_work+0xb9/0x2b8 [bluetooth]
       [<c103760a>] ? queue_delayed_work_on+0x21/0x2a
       [<c1035df9>] ? process_one_work+0x157/0x21b
       [<fb72785f>] ? hci_cmd_work+0xef/0xef [bluetooth]
       [<c1036217>] ? worker_thread+0x16e/0x20a
       [<c10360a9>] ? manage_workers+0x1cf/0x1cf
       [<c103a0ef>] ? kthread+0x8d/0x92
       [<c134adf7>] ? ret_from_kernel_thread+0x1b/0x28
       [<c103a062>] ? __init_kthread_worker+0x24/0x24
      BUG: unable to handle kernel NULL pointer dereference at   (null)
      IP: [<  (null)>]   (null)
      *pdpt = 00000000244e1001 *pde = 0000000000000000
      Oops: 0010 [#1] PREEMPT SMP
      Modules linked in: evdev ecb rfcomm(O) libcomposite usb2380 udc_core bnep(O) btusb(O) btbcm(O) cdc_acm btintel(O) bluetooth(O) arc4 uinput hid_multitouch usbhid hid iwlmvm(O)e
      Pid: 319, comm: kworker/u:2H Tainted: G           O 3.8.0-115.1-plk-adaptation-byt-ivi-brd #1
      EIP: 0060:[<00000000>] EFLAGS: 00010246 CPU: 0
      EIP is at 0x0
      EAX: e3e99400 EBX: e3e99400 ECX: 00000100 EDX: 00000000
      ESI: e3e99434 EDI: fb763ce0 EBP: e49b9e44 ESP: e49b9e14
       DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
      CR0: 8005003b CR2: 00000000 CR3: 24444000 CR4: 001007f0
      DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      DR6: ffff0ff0 DR7: 00000400
      Process kworker/u:2H (pid: 319, ti=e49b8000 task=e4ab9030 task.ti=e49b8000)
      Stack:
       fb75355b 00000246 fb763900 22222222 22222222 22222222 e3f94460 e3ca7c0a
       e49b9e4c e3f34c00 e3ca7c0a fb763ce0 e49b9e6c fb731dbc 02000246 e4cec85c
       e4cec008 00000000 e3f34c00 e4cec000 e3c2ce00 0000002c e49b9ed0 fb734ee7
      Call Trace:
       [<fb75355b>] ? sco_connect_cfm+0x9e/0x236 [bluetooth]
       [<fb731dbc>] ? hci_sync_conn_complete_evt.clone.101+0x18b/0x1cb [bluetooth]
       [<fb734ee7>] ? hci_event_packet+0x1acd/0x21a6 [bluetooth]
       [<c1041095>] ? finish_task_switch+0x50/0x89
       [<c1349a2e>] ? __schedule+0x638/0x6b8
       [<fb727918>] ? hci_rx_work+0xb9/0x2b8 [bluetooth]
       [<c103760a>] ? queue_delayed_work_on+0x21/0x2a
       [<c1035df9>] ? process_one_work+0x157/0x21b
       [<fb72785f>] ? hci_cmd_work+0xef/0xef [bluetooth]
       [<c1036217>] ? worker_thread+0x16e/0x20a
       [<c10360a9>] ? manage_workers+0x1cf/0x1cf
       [<c103a0ef>] ? kthread+0x8d/0x92
       [<c134adf7>] ? ret_from_kernel_thread+0x1b/0x28
       [<c103a062>] ? __init_kthread_worker+0x24/0x24
      Code:  Bad EIP value.
      EIP: [<00000000>] 0x0 SS:ESP 0068:e49b9e14
      CR2: 0000000000000000
      ---[ end trace 942a6577c0abd725 ]---
      Signed-off-by: NKuba Pawlak <kubax.t.pawlak@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      1da5537e
    • K
      Bluetooth: Fix locking issue on SCO disconnection · 435c5133
      Kuba Pawlak 提交于
      Thread handling SCO disconnection may get preempted in '__sco_sock_close'
      after dropping a reference to hci_conn but before marking this as NULL
      in associated struct sco_conn. When execution returs to this thread,
      this connection will possibly be released, resulting in kernel crash
      
      Lock connection before this point.
      
      BUG: unable to handle kernel NULL pointer dereference at   (null)
      IP: [<fb770ab9>] __sco_sock_close+0x194/0x1ff [bluetooth]
      *pdpt = 0000000023da6001 *pde = 0000000000000000
      Oops: 0002 [#1] PREEMPT SMP
      Modules linked in: evdev ecb rfcomm(O) libcomposite usb2380 udc_core bnep(O) btusb(O) btbcm(O) cdc_acm btintel(O) bluetooth(O) arc4 uinput hid_multitouch usbhid iwlmvm(O) hide
      Pid: 984, comm: bluetooth Tainted: G           O 3.8.0-115.1-plk-adaptation-byt-ivi-brd #1
      EIP: 0060:[<fb770ab9>] EFLAGS: 00010282 CPU: 2
      EIP is at __sco_sock_close+0x194/0x1ff [bluetooth]
      EAX: 00000000 EBX: e49d7600 ECX: ef1ec3c2 EDX: 000000c3
      ESI: e4c12000 EDI: 00000000 EBP: ef1edf5c ESP: ef1edf4c
       DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
      CR0: 80050033 CR2: 00000000 CR3: 23da7000 CR4: 001007f0
      DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      DR6: ffff0ff0 DR7: 00000400
      Process bluetooth (pid: 984, ti=ef1ec000 task=e47f2550 task.ti=ef1ec000)
      Stack:
       e4c120d0 e49d7600 00000000 08421a40 ef1edf70 fb770b7a 00000002 e8a4cc80
       08421a40 ef1ec000 c12966b1 00000001 00000000 0000000b 084954c8 c1296b6c
       0000001b 00000002 0000001b 00000002 00000000 00000002 b2524880 00000046
      Call Trace:
       [<fb770b7a>] ? sco_sock_shutdown+0x56/0x95 [bluetooth]
       [<c12966b1>] ? sys_shutdown+0x37/0x53
       [<c1296b6c>] ? sys_socketcall+0x12e/0x1be
       [<c134ae7e>] ? sysenter_do_call+0x12/0x26
       [<c1340000>] ? ip_vs_control_net_cleanup+0x46/0xb1
      Code: e8 90 6b 8c c5 f6 05 72 5d 78 fb 04 74 17 8b 46 08 50 56 68 0a fd 77 fb 68 60 5d 78 fb e8 68 95 9e c5 83 c4 10 8b 83 fc 01 00 00 <c7> 00 00 00 00 00 eb 32 ba 68 00 00 0b
      EIP: [<fb770ab9>] __sco_sock_close+0x194/0x1ff [bluetooth] SS:ESP 0068:ef1edf4c
      CR2: 0000000000000000
      ---[ end trace 47fa2f55a9544e69 ]---
      Signed-off-by: NKuba Pawlak <kubax.t.pawlak@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      435c5133
    • K
      Bluetooth: Fix crash on SCO disconnect · 75e34f5c
      Kuba Pawlak 提交于
      When disconnecting audio from the phone's side, it may happen, that
      a thread handling HCI message 'disconnection complete' will get preempted
      in 'sco_conn_del' before calling 'sco_sock_kill', still holding a pointer
      to struct sock sk. Interrupting thread started in 'sco_sock_shutdown' will
      carry on releasing resources and will eventually release struct sock.
      When execution goes back to first thread it will call sco_sock_kill using
      now invalid pointer to already destroyed socket.
      
      Fix is to grab a reference to the socket a release it after calling
      'sco_sock_kill'.
      
      [  166.358213] BUG: unable to handle kernel paging request at 7541203a
      [  166.365228] IP: [<fb6e8bfb>] bt_sock_unlink+0x1a/0x38 [bluetooth]
      [  166.372068] *pdpt = 0000000024b19001 *pde = 0000000000000000
      [  166.378483] Oops: 0002 [#1] PREEMPT SMP
      [  166.382871] Modules linked in: evdev ecb rfcomm(O) libcomposite usb2380 udc_core bnep(O) btusb(O) btbcm(O) btintel(O) cdc_acm bluetooth(O) arc4 uinput hid_multitouch iwlmvm(O) usbhid hide
      [  166.424233] Pid: 338, comm: kworker/u:2H Tainted: G           O 3.8.0-115.1-plk-adaptation-byt-ivi-brd #1
      [  166.435112] EIP: 0060:[<fb6e8bfb>] EFLAGS: 00010206 CPU: 0
      [  166.441259] EIP is at bt_sock_unlink+0x1a/0x38 [bluetooth]
      [  166.447382] EAX: 632e6563 EBX: e4bfc600 ECX: e466d4d3 EDX: 7541203a
      [  166.454369] ESI: fb7278ac EDI: e4d52000 EBP: e4669e20 ESP: e4669e0c
      [  166.461366]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
      [  166.467391] CR0: 8005003b CR2: 7541203a CR3: 24aba000 CR4: 001007f0
      [  166.474387] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      [  166.481375] DR6: ffff0ff0 DR7: 00000400
      [  166.485654] Process kworker/u:2H (pid: 338, ti=e4668000 task=e466e030 task.ti=e4668000)
      [  166.494591] Stack:
      [  166.496830]  e4bfc600 e4bfc600 fb715c28 e4717ee0 e4d52000 e4669e3c fb715cf3 e4bfc634
      [  166.505518]  00000068 e4d52000 e4c32000 fb7277c0 e4669e6c fb6f2019 0000004a 00000216
      [  166.514205]  e4660101 e4c32008 02000001 00000013 e4d52000 e4c32000 e3dc9240 00000005
      [  166.522891] Call Trace:
      [  166.525654]  [<fb715c28>] ? sco_sock_kill+0x73/0x9a [bluetooth]
      [  166.532295]  [<fb715cf3>] ? sco_conn_del+0xa4/0xbf [bluetooth]
      [  166.538836]  [<fb6f2019>] ? hci_disconn_complete_evt.clone.55+0x1bd/0x205 [bluetooth]
      [  166.547609]  [<fb6f73d3>] ? hci_event_packet+0x297/0x223c [bluetooth]
      [  166.554805]  [<c10416da>] ? dequeue_task+0xaf/0xb7
      [  166.560154]  [<c1041095>] ? finish_task_switch+0x50/0x89
      [  166.566086]  [<c1349a2e>] ? __schedule+0x638/0x6b8
      [  166.571460]  [<fb6eb906>] ? hci_rx_work+0xb9/0x2b8 [bluetooth]
      [  166.577975]  [<c1035df9>] ? process_one_work+0x157/0x21b
      [  166.583933]  [<fb6eb84d>] ? hci_cmd_work+0xef/0xef [bluetooth]
      [  166.590448]  [<c1036217>] ? worker_thread+0x16e/0x20a
      [  166.596088]  [<c10360a9>] ? manage_workers+0x1cf/0x1cf
      [  166.601826]  [<c103a0ef>] ? kthread+0x8d/0x92
      [  166.606691]  [<c134adf7>] ? ret_from_kernel_thread+0x1b/0x28
      [  166.613010]  [<c103a062>] ? __init_kthread_worker+0x24/0x24
      [  166.619230] Code: 85 63 ff ff ff 31 db 8d 65 f4 89 d8 5b 5e 5f 5d c3 56 8d 70 04 53 89 f0 89 d3 e8 7e 17 c6 c5 8b 53 28 85 d2 74 1a 8b 43 24 85 c0 <89> 02 74 03 89 50 04 c7 43 28 00 00 00
      [  166.640501] EIP: [<fb6e8bfb>] bt_sock_unlink+0x1a/0x38 [bluetooth] SS:ESP 0068:e4669e0c
      [  166.649474] CR2: 000000007541203a
      [  166.653420] ---[ end trace 0181ff2c9e42d51e ]---
      [  166.658609] note: kworker/u:2H[338] exited with preempt_count 1
      Signed-off-by: NKuba Pawlak <kubax.t.pawlak@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      75e34f5c
    • R
      NFC: nci: add nci_get_conn_info_by_id function · 85b9ce9a
      Robert Dolca 提交于
      This functin takes as a parameter a pointer to the nci_dev
      struct and the first byte from the values of the first domain
      specific parameter that was used for the connection creation.
      Signed-off-by: NRobert Dolca <robert.dolca@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      85b9ce9a
    • R
      NFC: nci: fix possible crash in nci_core_conn_create · caa575a8
      Robert Dolca 提交于
      If the number of destination speific parameters supplied is 0
      the call will fail. If the first destination specific parameter
      does not have a value, curr_id will be set to 0.
      Signed-off-by: NRobert Dolca <robert.dolca@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      caa575a8
    • R
      NFC: nci: rename nci_prop_ops to nci_driver_ops · 22e4bd09
      Robert Dolca 提交于
      Initially it was used to create hooks in the driver for
      proprietary operations. Currently it is being used for hooks
      for both proprietary and generic operations.
      Signed-off-by: NRobert Dolca <robert.dolca@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      22e4bd09
    • R
      NFC: nci: Allow the driver to set handler for core nci ops · 0a97a3cb
      Robert Dolca 提交于
      The driver may be required to act when some responses or
      notifications arrive. For example the NCI core does not have a
      handler for NCI_OP_CORE_GET_CONFIG_RSP. The NFCC can send a
      config response that has to be read by the driver and the packet
      may contain vendor specific data.
      
      The Fields Peak driver needs to take certain actions when a reset
      notification arrives (packet also not handled by the nfc core).
      
      The driver handlers do not interfere with the core and they are
      called after the core processes the packet.
      Signed-off-by: NRobert Dolca <robert.dolca@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      0a97a3cb
    • R
      NFC: nci: Introduce nci_core_cmd · 7bc4824e
      Robert Dolca 提交于
      This allows sending core commands from the driver. The driver
      should be able to send NCI core commands like CORE_GET_CONFIG_CMD.
      Signed-off-by: NRobert Dolca <robert.dolca@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      7bc4824e
    • R
      NFC: nci: Do not call post_setup when setup fails · e4dbd625
      Robert Dolca 提交于
      The driver should know that it can continue with post setup where
      setup left off. Being able to execute post_setup when setup fails
      may force the developer to keep this state in the driver.
      Signed-off-by: NRobert Dolca <robert.dolca@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      e4dbd625
    • R
      NFC: nci: Add function to get max packet size for conn · 2663589c
      Robert Dolca 提交于
      FDP driver needs to send the firmware as regular packets
      (not fragmented). The driver should have a way to
      get the max packet size for a given connection.
      Signed-off-by: NRobert Dolca <robert.dolca@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      2663589c
    • R
      NFC: nci: Export nci data send API · ea785c09
      Robert Dolca 提交于
      For the firmware update the driver may use nci_send_data.
      Signed-off-by: NRobert Dolca <robert.dolca@intel.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      ea785c09