Skip to content
  1. Sep 28, 2012
  2. Sep 27, 2012
    • Szymon Janc's avatar
      NFC: Fix sleeping in atomic when releasing socket · 50b78b2a
      Szymon Janc authored
      
      
      nfc_llcp_socket_release is calling lock_sock/release_sock while holding
      write lock for rwlock. Use bh_lock/unlock_sock instead.
      
      BUG: sleeping function called from invalid context at net/core/sock.c:2138
      in_atomic(): 1, irqs_disabled(): 0, pid: 56, name: kworker/1:1
      4 locks held by kworker/1:1/56:
      Pid: 56, comm: kworker/1:1 Not tainted 3.5.0-999-nfc+ #7
      Call Trace:
      [<ffffffff810952c5>] __might_sleep+0x145/0x200
      [<ffffffff815d7686>] lock_sock_nested+0x36/0xa0
      [<ffffffff81731569>] ? _raw_write_lock+0x49/0x50
      [<ffffffffa04aa100>] ? nfc_llcp_socket_release+0x30/0x200 [nfc]
      [<ffffffffa04aa122>] nfc_llcp_socket_release+0x52/0x200 [nfc]
      [<ffffffffa04ab9f0>] nfc_llcp_mac_is_down+0x20/0x30 [nfc]
      [<ffffffffa04a6fea>] nfc_dep_link_down+0xaa/0xf0 [nfc]
      [<ffffffffa04a9bb5>] nfc_llcp_timeout_work+0x15/0x20 [nfc]
      [<ffffffff810825f7>] process_one_work+0x197/0x7c0
      [<ffffffff81082596>] ? process_one_work+0x136/0x7c0
      [<ffffffff8172fbc9>] ? __schedule+0x419/0x9c0
      [<ffffffffa04a9ba0>] ? nfc_llcp_build_gb+0x1b0/0x1b0 [nfc]
      [<ffffffff81083090>] worker_thread+0x190/0x4c0
      [<ffffffff81082f00>] ? rescuer_thread+0x2a0/0x2a0
      [<ffffffff81088d1e>] kthread+0xae/0xc0
      [<ffffffff810caafd>] ? trace_hardirqs_on+0xd/0x10
      [<ffffffff8173acc4>] kernel_thread_helper+0x4/0x10
      [<ffffffff81732174>] ? retint_restore_args+0x13/0x13
      [<ffffffff81088c70>] ? flush_kthread_worker+0x150/0x150
      [<ffffffff8173acc0>] ? gs_change+0x13/0x13
      
      Signed-off-by: default avatarSzymon Janc <szymon.janc@tieto.com>
      Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
      50b78b2a
    • Szymon Janc's avatar
      NFC: Fix sleeping in invalid context when netlink socket is closed · 3c0cc8aa
      Szymon Janc authored
      
      
      netlink_register_notifier requires notify functions to not sleep.
      nfc_stop_poll locks device mutex and must not be called from notifier.
      Create workqueue that will handle this for all devices.
      
      BUG: sleeping function called from invalid context at kernel/mutex.c:269
      in_atomic(): 0, irqs_disabled(): 0, pid: 4497, name: neard
      1 lock held by neard/4497:
      Pid: 4497, comm: neard Not tainted 3.5.0-999-nfc+ #5
      Call Trace:
      [<ffffffff810952c5>] __might_sleep+0x145/0x200
      [<ffffffff81743dde>] mutex_lock_nested+0x2e/0x50
      [<ffffffff816ffd19>] nfc_stop_poll+0x39/0xb0
      [<ffffffff81700a17>] nfc_genl_rcv_nl_event+0x77/0xc0
      [<ffffffff8174aa8c>] notifier_call_chain+0x5c/0x120
      [<ffffffff8174abd6>] __atomic_notifier_call_chain+0x86/0x140
      [<ffffffff8174ab50>] ? notifier_call_chain+0x120/0x120
      [<ffffffff815e1347>] ? skb_dequeue+0x67/0x90
      [<ffffffff8174aca6>] atomic_notifier_call_chain+0x16/0x20
      [<ffffffff8162119a>] netlink_release+0x24a/0x280
      [<ffffffff815d7aa8>] sock_release+0x28/0xa0
      [<ffffffff815d7be7>] sock_close+0x17/0x30
      [<ffffffff811b2a7c>] __fput+0xcc/0x250
      [<ffffffff811b2c0e>] ____fput+0xe/0x10
      [<ffffffff81085009>] task_work_run+0x69/0x90
      [<ffffffff8101b951>] do_notify_resume+0x81/0xd0
      [<ffffffff8174ef22>] int_signal+0x12/0x17
      
      Signed-off-by: default avatarSzymon Janc <szymon.janc@tieto.com>
      Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
      3c0cc8aa
    • John W. Linville's avatar
      NFC: Add dummy nfc_llc_shdlc_register definition · 7d777c3d
      John W. Linville authored
      
      
      This is used when CONFIG_NFC_SHDLC is disabled.
      
      Reported-by: default avatarRandy Dunlap <rdunlap@xenotime.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
      7d777c3d
    • Thierry Escande's avatar
      NFC: LLCP raw socket support · 4463523b
      Thierry Escande authored
      
      
      This adds support for socket of type SOCK_RAW to LLCP.
      sk_buff are copied and sent to raw sockets with a 2 bytes extra header:
      The first byte header contains the nfc adapter index.
      The second one contains flags:
      - 0x01 - Direction (0=RX, 1=TX)
      - 0x02-0x80 - Reserved
      A raw socket has to be explicitly bound to a nfc adapter. This is achieved
      by specifying the adapter index to be bound to in the dev_idx field of the
      sockaddr_nfc_llcp struct passed to bind().
      
      Signed-off-by: default avatarThierry Escande <thierry.escande@linux.intel.com>
      Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
      4463523b
    • Szymon Janc's avatar
      NFC: Fix missing mutex unlock in pn533_send_cmd_frame_async · ee5e8d81
      Szymon Janc authored
      
      
      If command allocation failed cmd_lock was not released and deadlock
      would occur.
      
      Signed-off-by: default avatarSzymon Janc <szymon.janc@tieto.com>
      Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
      ee5e8d81
    • Szymon Janc's avatar
      NFC: Use dynamic initialization for rwlocks · fe235b58
      Szymon Janc authored
      
      
      If rwlock is dynamically allocated but statically initialized it is
      missing proper lockdep annotation.
      
      INFO: trying to register non-static key.
      the code is fine but needs lockdep annotation.
      turning off the locking correctness validator.
      Pid: 3352, comm: neard Not tainted 3.5.0-999-nfc+ #2
      Call Trace:
      [<ffffffff810c8526>] __lock_acquire+0x8f6/0x1bf0
      [<ffffffff81739045>] ? printk+0x4d/0x4f
      [<ffffffff810c9eed>] lock_acquire+0x9d/0x220
      [<ffffffff81702bfe>] ? nfc_llcp_sock_from_sn+0x4e/0x160
      [<ffffffff81746724>] _raw_read_lock+0x44/0x60
      [<ffffffff81702bfe>] ? nfc_llcp_sock_from_sn+0x4e/0x160
      [<ffffffff81702bfe>] nfc_llcp_sock_from_sn+0x4e/0x160
      [<ffffffff817034a7>] nfc_llcp_get_sdp_ssap+0xa7/0x1b0
      [<ffffffff81706353>] llcp_sock_bind+0x173/0x210
      [<ffffffff815d9c94>] sys_bind+0xe4/0x100
      [<ffffffff8139209e>] ? trace_hardirqs_on_thunk+0x3a/0x3f
      [<ffffffff8174ea69>] system_call_fastpath+0x16/0x1b
      
      Signed-off-by: default avatarSzymon Janc <szymon.janc@tieto.com>
      Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
      fe235b58
    • John W. Linville's avatar
      nfc: add dummy nfc_llc_shdlc_register definition · 8a14e8bf
      John W. Linville authored
      
      
      This is used when CONFIG_NFC_SHDLC is disabled.
      
      Reported-by: default avatarRandy Dunlap <rdunlap@xenotime.net>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      8a14e8bf
  3. Sep 26, 2012