All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: core: Replace fput with sockfd_put
@ 2020-12-29 13:48 Zheng Yongjun
  2020-12-29 15:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Zheng Yongjun @ 2020-12-29 13:48 UTC (permalink / raw)
  To: john.fastabend, daniel, jakub, lmb, davem, kuba, netdev, bpf,
	linux-kernel
  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.

The problem was fixed using the following semantic patch.
    (http://www.emn.fr/x-info/coccinelle/)

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

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

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 net/core/sock_map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index ddc899e83313..2e59256a06e9 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -611,7 +611,7 @@ int sock_map_update_elem_sys(struct bpf_map *map, void *key, void *value,
 		ret = sock_hash_update_common(map, key, sk, flags);
 	sock_map_sk_release(sk);
 out:
-	fput(sock->file);
+	sockfd_put(sock);
 	return ret;
 }
 
-- 
2.22.0


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

* Re: [PATCH net-next] net: core: Replace fput with sockfd_put
  2020-12-29 13:48 [PATCH net-next] net: core: Replace fput with sockfd_put Zheng Yongjun
@ 2020-12-29 15:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-12-29 15:40 UTC (permalink / raw)
  To: Zheng Yongjun
  Cc: john.fastabend, daniel, jakub, lmb, davem, kuba, netdev, bpf,
	linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Tue, 29 Dec 2020 21:48:34 +0800 you wrote:
> 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.
> 
> The problem was fixed using the following semantic patch.
>     (http://www.emn.fr/x-info/coccinelle/)
> 
> [...]

Here is the summary with links:
  - [net-next] net: core: Replace fput with sockfd_put
    https://git.kernel.org/bpf/bpf-next/c/f734031bb4c7

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2020-12-29 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29 13:48 [PATCH net-next] net: core: Replace fput with sockfd_put Zheng Yongjun
2020-12-29 15:40 ` patchwork-bot+netdevbpf

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.