Skip to contentSkip to conversation

bpf: put file handler if no storage found

PATCH Applied Pan Bian 2 participants 2 messages Jan 21, 2021 – Jan 22, 2021

Subsystems (3)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 bpf: put file handler if no storage found

Put file f if inode_storage_ptr() returns NULL.

Fixes 8ea636848aca ("bpf: Implement bpf_local_storage for inodes")
---
 kernel/bpf/bpf_inode_storage.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/bpf/bpf_inode_storage.c +5 -1
index 6edff97ad594..089d5071d4fc 100644
@@ -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,
Signature · 1 line
2.17.1
#1 lore raw
This patch was applied to bpf/bpf.git (refs/heads/master):

Hello:

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

Quoted 8 lines · 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")
---
 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