diff mbox series

[net-next] net: add sanity check in proto_register()

Message ID 20220216171801.3604366-1-eric.dumazet@gmail.com (mailing list archive)
State Accepted
Commit f20cfd662a62dc62c25d9feff29eadc600455ca7
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: add sanity check in proto_register() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 6 this patch: 6
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 11 this patch: 11
netdev/checkpatch warning WARNING: Unknown commit id '25206111512d', maybe rebased or not pulled?
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eric Dumazet Feb. 16, 2022, 5:18 p.m. UTC
From: Eric Dumazet <edumazet@google.com>

prot->memory_allocated should only be set if prot->sysctl_mem
is also set.

This is a followup of commit 25206111512d ("crypto: af_alg - get
rid of alg_memory_allocated").

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/sock.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

patchwork-bot+netdevbpf@kernel.org Feb. 18, 2022, 5 a.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 16 Feb 2022 09:18:01 -0800 you wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> prot->memory_allocated should only be set if prot->sysctl_mem
> is also set.
> 
> This is a followup of commit 25206111512d ("crypto: af_alg - get
> rid of alg_memory_allocated").
> 
> [...]

Here is the summary with links:
  - [net-next] net: add sanity check in proto_register()
    https://git.kernel.org/netdev/net-next/c/f20cfd662a62

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/sock.c b/net/core/sock.c
index 09d31a7dc68f88af42f75f3f445818fe273b04fb..d76218ab4999922879401262ba873b62aff943a0 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -3718,6 +3718,10 @@  int proto_register(struct proto *prot, int alloc_slab)
 {
 	int ret = -ENOBUFS;
 
+	if (prot->memory_allocated && !prot->sysctl_mem) {
+		pr_err("%s: missing sysctl_mem\n", prot->name);
+		return -EINVAL;
+	}
 	if (alloc_slab) {
 		prot->slab = kmem_cache_create_usercopy(prot->name,
 					prot->obj_size, 0,