Skip to contentSkip to conversation

NFC: fdp: Fix a signedness bug in fdp_nci_send_patch()

PATCH In review Dan Carpenter 2 participants 2 messages Mar 20, 2020 – Mar 24, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFC: fdp: Fix a signedness bug in fdp_nci_send_patch()

The nci_conn_max_data_pkt_payload_size() function sometimes returns -EPROTO so "max_size" needs to be signed for the error handling to work. We can make "payload_size" an int as well.

Fixes a06347c04c13 ("NFC: Add Intel Fields Peak NFC solution driver")
---
 drivers/nfc/fdp/fdp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/nfc/fdp/fdp.c +2 -3
index 7c0b1e6b80ff..4dc7bd7e02b6 100644
@@ -184,7 +184,7 @@ static int fdp_nci_send_patch(struct nci_dev *ndev, u8 conn_id, u8 type)
 	const struct firmware *fw;
 	struct sk_buff *skb;
 	unsigned long len;
-	u8 max_size, payload_size;
+	int max_size, payload_size;
 	int rc = 0;
 
 	if ((type = NCI_PATCH_TYPE_OTP && !info->otp_patch) ||
@@ -207,8 +207,7 @@ static int fdp_nci_send_patch(struct nci_dev *ndev, u8 conn_id, u8 type)
 
 	while (len) {
 
-		payload_size = min_t(unsigned long, (unsigned long) max_size,
-				     len);
+		payload_size = min_t(unsigned long, max_size, len);
 
 		skb = nci_skb_alloc(ndev, (NCI_CTRL_HDR_SIZE + payload_size),
 				    GFP_KERNEL);
Signature · 1 line
2.20.1
maintainer
#1 lore raw

From: Dan Carpenter <[email protected]>
Date: Fri, 20 Mar 2020 16:21:17 +0300

Quoted 6 lines

The nci_conn_max_data_pkt_payload_size() function sometimes returns -EPROTO so "max_size" needs to be signed for the error handling to work. We can make "payload_size" an int as well.

Fixes a06347c04c13 ("NFC: Add Intel Fields Peak NFC solution driver")

Applied and queued up for -stable, thanks Dan.