Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp914844imu; Fri, 9 Nov 2018 08:04:30 -0800 (PST) X-Google-Smtp-Source: AJdET5fxSMawnnuDVcUpXecGMKShMY6VJ4igfIwB58MNGqqCgDQ1xRBYeIcgwOk+4UhnyI/1MTSv X-Received: by 2002:a63:5f95:: with SMTP id t143mr8057207pgb.395.1541779470601; Fri, 09 Nov 2018 08:04:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541779470; cv=none; d=google.com; s=arc-20160816; b=cmcenU9PbdaWFqfgxZL6KUkrgDp27gPde+6jaWPd7R25VVebZWeudyYUfnfaHM+n4m gVpBLi1M/lwjOiKJIX+Bt8wtU8wmkZYi1R1YxpEIj9wP+z7+Vj4HxGwfPHJuyQok2nGW xoqDwqQkSMe3zjK1GG+OlNWajlZBAXzHPbbAQLuLfmJs1GrWvtbc/5d/H6plbh8vQaZY FDExHZUO+U5aYW1P+p3gjD8z0YYR4F9HmTwzMQSFQyuVvYW4/oPnsIVWRlfo+gDJvPf+ Wbyv4AKTByFlW7Tuhz02JMRjgt4qqIeo0eXgYEDW6RWz6WpgAT9GprShIFwmsTZmUEcs x44w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=gNq5aLGpfRVlZnImt7AN3MfmXGImBnKyPEMZCcianDk=; b=xXMFQ3BvHxxdM6U7hshkb3RC1Xxl6BDctihzrMhhoWdjDUQ0JVpi3RPsJSe71jNZVX mY4kDH+dqrBWNMVdsb5Ug9LXi2E3O2yMFF5of5q3Uy0uMfjZQ4DBnlLlxLYw7J8I8R91 SNo9y6oTVDi08WzwqULfKG8xkkFxoA63d9KGUSfDQT/WHbDwVMKNxr13ESQJGmU0S8Mu /69ZNfNtl5sY03NBXIK2nvgmYLSQoCdMV2jUM0RlfHxvPgXlYB0L4eA9UIoYc4c3QM3X XjENIcOedOcZ69bafO8x0dWryr2eE4XsHDFEb0wXFeZHHLe44il/cnUueb4Dn8A0C3yH Xfrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6-v6si7869483plt.330.2018.11.09.08.03.04; Fri, 09 Nov 2018 08:04:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728148AbeKJBmw (ORCPT + 99 others); Fri, 9 Nov 2018 20:42:52 -0500 Received: from gw.hale.at ([89.26.116.210]:51598 "EHLO gw.hale.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbeKJBmw (ORCPT ); Fri, 9 Nov 2018 20:42:52 -0500 X-HALE-Mailborder-Watermark: 1542384098.42688@F2Nco1YLxCKxPERdX17yaA X-HALE-Mailborder-From: michael.thalmeier@hale.at X-HALE-Mailborder-SpamCheck: not spam, SpamAssassin (nicht zwischen gespeichert, Wertung=-2.899, benoetigt 3, autolearn=not spam, ALL_TRUSTED -1.00, BAYES_00 -1.90, SURBL_BLOCKED 0.00) X-HALE-Mailborder-IP-Protocol: IPv4 X-HALE-Mailborder: Found to be clean X-HALE-Mailborder-ID: 63E6F2C1BE8.AABDB X-HALE-Mailborder-Information: Please contact your admin for more information Received: from mail.hale (mail.hale [192.168.100.5]) by gw.hale.at (Postfix) with ESMTP id 63E6F2C1BE8; Fri, 9 Nov 2018 17:01:35 +0100 (CET) Received: from mail.hale (localhost.localdomain [127.0.0.1]) by mail.hale (Postfix) with ESMTP id 5E04F660D0B; Fri, 9 Nov 2018 17:01:35 +0100 (CET) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.hale (Postfix) with ESMTP id 5193F660CC2; Fri, 9 Nov 2018 17:01:35 +0100 (CET) Received: from mail.hale ([127.0.0.1]) by localhost (mail.hale [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id rAkxE8y98vVO; Fri, 9 Nov 2018 17:01:35 +0100 (CET) Received: from entw49.HALE (entw49.hale [192.168.100.117]) by mail.hale (Postfix) with ESMTP id 360286605E0; Fri, 9 Nov 2018 17:01:35 +0100 (CET) From: Michael Thalmeier To: Samuel Ortiz Cc: Michael Thalmeier , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-nfc@lists.01.org Subject: [PATCH] NFC: nci: clear NCI_DATA_EXCHANGE before calling the NFC stack callback Date: Fri, 9 Nov 2018 17:01:18 +0100 Message-Id: <20181109160118.32737-1-michael.thalmeier@hale.at> X-Mailer: git-send-email 2.9.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Thalmeier By calling the nfc core callback (cb) in nci_data_exchange_complete the userspace task will get notified that response data is available for the current request. When the userspace task then reads the return data and immediately issues another request, it was possible that this will be done before the NCI_DATA_EXCHANGE is cleared. The result is that nci_transceive will return -EBUSY and the NFC stack (rawsock.c:rawsock_tx_work) will report an error and shut down the socket. Not only is this quite a harsh behaviour for this situation, but additionally any following attempt to poll for NFC tags will result in an error "there is an active target" since the previous active tag is not cleanly deactivated. With this change NCI_DATA_EXCHANGE will get cleard before calling into the NFC stack, which fixes this situation. Signed-off-by: Michael Thalmeier --- net/nfc/nci/data.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c index 908f25e..57d5980 100644 --- a/net/nfc/nci/data.c +++ b/net/nfc/nci/data.c @@ -56,6 +56,7 @@ void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, /* data exchange is complete, stop the data timer */ del_timer_sync(&ndev->data_timer); clear_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags); + clear_bit(NCI_DATA_EXCHANGE, &ndev->flags); if (cb) { /* forward skb to nfc core */ @@ -66,6 +67,7 @@ void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, /* no waiting callback, free skb */ kfree_skb(skb); } + return; exit: clear_bit(NCI_DATA_EXCHANGE, &ndev->flags); -- 2.9.2