linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Module Name: drivers/nfc/pn544/pn544.c    fix a bug
@ 2021-12-25 13:27 hrshy0629
  2021-12-26 11:31 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: hrshy0629 @ 2021-12-25 13:27 UTC (permalink / raw)
  To: krzysztof.kozlowski, davem; +Cc: kuba, linux-kernel, hrshy0629

    I noticed that the same usage for API nfc_hci_send_cmd() in line 541 and line 552 of the file pn544.c.
    And the variable r is checked on line 545 but not checked on line 552.
    The r in line 552 should be checked.

Signed-off-by: hrshy0629 <hongqiang601217@gmail.com>
---
 drivers/nfc/pn544/pn544.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c
index 32a61a185142..531eda0d11a2 100644
--- a/drivers/nfc/pn544/pn544.c
+++ b/drivers/nfc/pn544/pn544.c
@@ -552,6 +552,8 @@ static int pn544_hci_complete_target_discovered(struct nfc_hci_dev *hdev,
 			r = nfc_hci_send_cmd(hdev, PN544_RF_READER_F_GATE,
 					     PN544_RF_READER_CMD_ACTIVATE_NEXT,
 					     uid_skb->data, uid_skb->len, NULL);
+			if (r < 0)
+				return r;
 			kfree_skb(uid_skb);
 		}
 	} else if (target->supported_protocols & NFC_PROTO_ISO14443_MASK) {
-- 
2.17.1


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

* Re: [PATCH] Module Name: drivers/nfc/pn544/pn544.c fix a bug
  2021-12-25 13:27 [PATCH] Module Name: drivers/nfc/pn544/pn544.c fix a bug hrshy0629
@ 2021-12-26 11:31 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2021-12-26 11:31 UTC (permalink / raw)
  To: hrshy0629, davem; +Cc: kuba, linux-kernel

On 25/12/2021 14:27, hrshy0629 wrote:
>     I noticed that the same usage for API nfc_hci_send_cmd() in line 541 and line 552 of the file pn544.c.
>     And the variable r is checked on line 545 but not checked on line 552.
>     The r in line 552 should be checked.

Why 'r' should be tested and returned early in line 552? Just because
some other code has slightly similar pattern, does not mean you should
apply it everywhere blindly.

Patch title and description is not matching coding style. Please, go via
git history to find how it is being written.

Title must describe what bug exactly you fix. Use imperative mode in the
commit description. Describe what is the bug and h ow it should be fixed.

> 
> Signed-off-by: hrshy0629 <hongqiang601217@gmail.com>
> ---
>  drivers/nfc/pn544/pn544.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c
> index 32a61a185142..531eda0d11a2 100644
> --- a/drivers/nfc/pn544/pn544.c
> +++ b/drivers/nfc/pn544/pn544.c
> @@ -552,6 +552,8 @@ static int pn544_hci_complete_target_discovered(struct nfc_hci_dev *hdev,
>  			r = nfc_hci_send_cmd(hdev, PN544_RF_READER_F_GATE,
>  					     PN544_RF_READER_CMD_ACTIVATE_NEXT,
>  					     uid_skb->data, uid_skb->len, NULL);
> +			if (r < 0)
> +				return r;

This looks like creating a leak, so NAK. Please provide explanation why
such error patch should be used.

>  			kfree_skb(uid_skb);


Best regards,
Krzysztof

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

end of thread, other threads:[~2021-12-26 11:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-25 13:27 [PATCH] Module Name: drivers/nfc/pn544/pn544.c fix a bug hrshy0629
2021-12-26 11:31 ` Krzysztof Kozlowski

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).