All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] NFC: netlink: put device in nfc_genl_se_io()
@ 2023-01-05  8:27 Zhengchao Shao
  2023-01-05 13:55 ` Jiri Pirko
  2023-01-06  6:18 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Zhengchao Shao @ 2023-01-05  8:27 UTC (permalink / raw)
  To: netdev, krzysztof.kozlowski, davem, edumazet, kuba, pabeni
  Cc: sameo, weiyongjun1, yuehaibing, shaozhengchao

When nfc_genl_se_io() function is called, no matter it failed or succeed,
it does not put device. Fix it.

Fixes: 5ce3f32b5264 ("NFC: netlink: SE API implementation")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 net/nfc/netlink.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 9d91087b9399..86601d400bd6 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -1497,6 +1497,7 @@ static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info)
 	u32 dev_idx, se_idx;
 	u8 *apdu;
 	size_t apdu_len;
+	int ret;
 
 	if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
 	    !info->attrs[NFC_ATTR_SE_INDEX] ||
@@ -1510,25 +1511,37 @@ static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info)
 	if (!dev)
 		return -ENODEV;
 
-	if (!dev->ops || !dev->ops->se_io)
-		return -ENOTSUPP;
+	if (!dev->ops || !dev->ops->se_io) {
+		ret = -EOPNOTSUPP;
+		goto out;
+	}
 
 	apdu_len = nla_len(info->attrs[NFC_ATTR_SE_APDU]);
-	if (apdu_len == 0)
-		return -EINVAL;
+	if (apdu_len == 0) {
+		ret = -EINVAL;
+		goto out;
+	}
 
 	apdu = nla_data(info->attrs[NFC_ATTR_SE_APDU]);
-	if (!apdu)
-		return -EINVAL;
+	if (!apdu) {
+		ret = -EINVAL;
+		goto out;
+	}
 
 	ctx = kzalloc(sizeof(struct se_io_ctx), GFP_KERNEL);
-	if (!ctx)
-		return -ENOMEM;
+	if (!ctx) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	ctx->dev_idx = dev_idx;
 	ctx->se_idx = se_idx;
 
-	return nfc_se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx);
+	ret = nfc_se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx);
+
+out:
+	nfc_put_device(dev);
+	return ret;
 }
 
 static int nfc_genl_vendor_cmd(struct sk_buff *skb,
-- 
2.34.1


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

* Re: [PATCH net] NFC: netlink: put device in nfc_genl_se_io()
  2023-01-05  8:27 [PATCH net] NFC: netlink: put device in nfc_genl_se_io() Zhengchao Shao
@ 2023-01-05 13:55 ` Jiri Pirko
  2023-01-06  6:18 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2023-01-05 13:55 UTC (permalink / raw)
  To: Zhengchao Shao
  Cc: netdev, krzysztof.kozlowski, davem, edumazet, kuba, pabeni,
	sameo, weiyongjun1, yuehaibing

Thu, Jan 05, 2023 at 09:27:38AM CET, shaozhengchao@huawei.com wrote:
>When nfc_genl_se_io() function is called, no matter it failed or succeed,
>it does not put device. Fix it.
>
>Fixes: 5ce3f32b5264 ("NFC: netlink: SE API implementation")
>Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

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

* Re: [PATCH net] NFC: netlink: put device in nfc_genl_se_io()
  2023-01-05  8:27 [PATCH net] NFC: netlink: put device in nfc_genl_se_io() Zhengchao Shao
  2023-01-05 13:55 ` Jiri Pirko
@ 2023-01-06  6:18 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2023-01-06  6:18 UTC (permalink / raw)
  To: Zhengchao Shao
  Cc: netdev, krzysztof.kozlowski, davem, edumazet, pabeni, sameo,
	weiyongjun1, yuehaibing

On Thu, 5 Jan 2023 16:27:38 +0800 Zhengchao Shao wrote:
> When nfc_genl_se_io() function is called, no matter it failed or succeed,
> it does not put device. Fix it.
> 
> Fixes: 5ce3f32b5264 ("NFC: netlink: SE API implementation")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>

Does not apply

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

end of thread, other threads:[~2023-01-06  6:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05  8:27 [PATCH net] NFC: netlink: put device in nfc_genl_se_io() Zhengchao Shao
2023-01-05 13:55 ` Jiri Pirko
2023-01-06  6:18 ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.