[PATCH] bpf: put file handler if no storage found

Subsystems: bpf [general] (safe dynamic programs and tools), the rest

STALE2030d LANDED: 1 (1M)

1 review trailer; landed in mainline as b9557caaf872 on 2021-01-22.

2 messages, 2 authors, 2021-01-22 · open the first message on its own page

[PATCH] bpf: put file handler if no storage found

From: Pan Bian <hidden>
Date: 2021-01-21 02:35:40

Put file f if inode_storage_ptr() returns NULL.

Fixes: 8ea636848aca ("bpf: Implement bpf_local_storage for inodes")
Acked-by: KP Singh <kpsingh@kernel.org>
Signed-off-by: Pan Bian <redacted>
---
 kernel/bpf/bpf_inode_storage.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/bpf_inode_storage.c b/kernel/bpf/bpf_inode_storage.c
index 6edff97ad594..089d5071d4fc 100644
--- a/kernel/bpf/bpf_inode_storage.c
+++ b/kernel/bpf/bpf_inode_storage.c
@@ -125,8 +125,12 @@ static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,
 
 	fd = *(int *)key;
 	f = fget_raw(fd);
-	if (!f || !inode_storage_ptr(f->f_inode))
+	if (!f)
+		return -EBADF;
+	if (!inode_storage_ptr(f->f_inode)) {
+		fput(f);
 		return -EBADF;
+	}
 
 	sdata = bpf_local_storage_update(f->f_inode,
 					 (struct bpf_local_storage_map *)map,
-- 
2.17.1

Re: [PATCH] bpf: put file handler if no storage found

From: patchwork-bot+netdevbpf@kernel.org
Date: 2021-01-22 22:21:29

Hello:

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

On Wed, 20 Jan 2021 18:08:56 -0800 you wrote:
Put file f if inode_storage_ptr() returns NULL.

Fixes: 8ea636848aca ("bpf: Implement bpf_local_storage for inodes")
Acked-by: KP Singh <kpsingh@kernel.org>
Signed-off-by: Pan Bian <redacted>
---
 kernel/bpf/bpf_inode_storage.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Here is the summary with links:
  - bpf: put file handler if no storage found
    https://git.kernel.org/bpf/bpf/c/524db191d2f5

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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help