linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] nfc: s3fwrn5: replace the assertion with a WARN_ON
@ 2019-12-17 20:43 Aditya Pakki
  2019-12-20  1:33 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2019-12-17 20:43 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Robert Baldyga, Krzysztof Opasiak, linux-nfc, netdev, linux-kernel

In s3fwrn5_fw_recv_frame, if fw_info->rsp is not empty, the
current code causes a crash via BUG_ON. However, s3fwrn5_fw_send_msg
does not crash in such a scenario. The patch replaces the BUG_ON
by returning the error to the callers and frees up skb.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
v1: Failed to free memory of skb, identified by David Miller
---
 drivers/nfc/s3fwrn5/firmware.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c
index be110d9cef02..de613c623a2c 100644
--- a/drivers/nfc/s3fwrn5/firmware.c
+++ b/drivers/nfc/s3fwrn5/firmware.c
@@ -507,7 +507,10 @@ int s3fwrn5_fw_recv_frame(struct nci_dev *ndev, struct sk_buff *skb)
 	struct s3fwrn5_info *info = nci_get_drvdata(ndev);
 	struct s3fwrn5_fw_info *fw_info = &info->fw_info;
 
-	BUG_ON(fw_info->rsp);
+	if (WARN_ON(fw_info->rsp)) {
+		kfree_skb(skb);
+		return -EINVAL;
+	}
 
 	fw_info->rsp = skb;
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] nfc: s3fwrn5: replace the assertion with a WARN_ON
  2019-12-17 20:43 [PATCH v2] nfc: s3fwrn5: replace the assertion with a WARN_ON Aditya Pakki
@ 2019-12-20  1:33 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-12-20  1:33 UTC (permalink / raw)
  To: pakki001; +Cc: kjlu, r.baldyga, k.opasiak, linux-nfc, netdev, linux-kernel

From: Aditya Pakki <pakki001@umn.edu>
Date: Tue, 17 Dec 2019 14:43:00 -0600

> In s3fwrn5_fw_recv_frame, if fw_info->rsp is not empty, the
> current code causes a crash via BUG_ON. However, s3fwrn5_fw_send_msg
> does not crash in such a scenario. The patch replaces the BUG_ON
> by returning the error to the callers and frees up skb.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-20  1:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17 20:43 [PATCH v2] nfc: s3fwrn5: replace the assertion with a WARN_ON Aditya Pakki
2019-12-20  1:33 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).