netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 net-next] net: kcm: Replace fput with sockfd_put
@ 2020-12-30  9:18 Zheng Yongjun
  2021-01-06  0:02 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Zheng Yongjun @ 2020-12-30  9:18 UTC (permalink / raw)
  To: davem, kuba, netdev, linux-kernel, Markus.Elring; +Cc: Zheng Yongjun

The function sockfd_lookup uses fget on the value that is stored in
the file field of the returned structure, so fput should ultimately be
applied to this value.  This can be done directly, but it seems better
to use the specific macro sockfd_put, which does the same thing.

Perform a source code refactoring by using the following semantic patch.

    // <smpl>
    @@
    expression s;
    @@

       s = sockfd_lookup(...)
       ...
    + sockfd_put(s);
    - fput(s->file);
    // </smpl>

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 net/kcm/kcmsock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 56dad9565bc9..a9eb616f5521 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1496,7 +1496,7 @@ static int kcm_attach_ioctl(struct socket *sock, struct kcm_attach *info)
 
 	return 0;
 out:
-	fput(csock->file);
+	sockfd_put(csock);
 	return err;
 }
 
@@ -1644,7 +1644,7 @@ static int kcm_unattach_ioctl(struct socket *sock, struct kcm_unattach *info)
 	spin_unlock_bh(&mux->lock);
 
 out:
-	fput(csock->file);
+	sockfd_put(csock);
 	return err;
 }
 
-- 
2.22.0


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

* Re: [PATCH v3 net-next] net: kcm: Replace fput with sockfd_put
  2020-12-30  9:18 [PATCH v3 net-next] net: kcm: Replace fput with sockfd_put Zheng Yongjun
@ 2021-01-06  0:02 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2021-01-06  0:02 UTC (permalink / raw)
  To: zhengyongjun3; +Cc: kuba, netdev, linux-kernel, Markus.Elring

From: Zheng Yongjun <zhengyongjun3@huawei.com>
Date: Wed, 30 Dec 2020 17:18:09 +0800

> The function sockfd_lookup uses fget on the value that is stored in
> the file field of the returned structure, so fput should ultimately be
> applied to this value.  This can be done directly, but it seems better
> to use the specific macro sockfd_put, which does the same thing.
> 
> Perform a source code refactoring by using the following semantic patch.
> 
>     // <smpl>
>     @@
>     expression s;
>     @@
> 
>        s = sockfd_lookup(...)
>        ...
>     + sockfd_put(s);
>     - fput(s->file);
>     // </smpl>
> 
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>

Applied.

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

end of thread, other threads:[~2021-01-06  0:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30  9:18 [PATCH v3 net-next] net: kcm: Replace fput with sockfd_put Zheng Yongjun
2021-01-06  0:02 ` 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).