nci_to_errno() returns negative errno values for nonzero data-status bytes. Passing that value to nci_add_rx_data_frag() through a __u8 parameter truncates the signed errno into an unrelated positive value before the completion callback receives it. For userspace AF_NFC raw sockets, this corrupts the reported error: for example, an NCI status error mapped to -EBUSY (-16) is truncated to 240 and negated to SO_ERROR=-240 instead of reporting EBUSY (16). Keep the error parameter as int so the original errno reaches the completion path and userspace unchanged. Fixes: 98ff416f97c5 ("NFC: nci: Add status byte management in case of error.") Cc: stable@vger.kernel.org Signed-off-by: Bin Luo (University of Electronic Science and Technology of China) --- net/nfc/nci/data.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c index 3bbebb9..4a2326a 100644 --- a/net/nfc/nci/data.c +++ b/net/nfc/nci/data.c @@ -213,13 +213,11 @@ EXPORT_SYMBOL(nci_send_data); static void nci_add_rx_data_frag(struct nci_dev *ndev, struct sk_buff *skb, - __u8 pbf, __u8 conn_id, __u8 status) + __u8 pbf, __u8 conn_id, int err) { int reassembly_len; - int err = 0; - if (status) { - err = status; + if (err) { kfree_skb(ndev->rx_data_reassembly); ndev->rx_data_reassembly = NULL; goto exit; -- 2.43.0