Skip to contentSkip to conversation

netfilter: nft_compat: use .release_ops and remove list of extension

bug report Dan Carpenter 1 participant 1 message Mar 5, 2019 netfilter

lore
Share & tools
lore
#0 lore raw

Hello Pablo Neira Ayuso,

The patch b8e204006340: "netfilter: nft_compat: use .release_ops and remove list of extension" from Feb 13, 2019, leads to the following static checker warning:

	net/netfilter/nf_tables_api.c:2167 nf_tables_expr_destroy()
	error: dereferencing freed memory 'expr->ops'

net/netfilter/nf_tables_api.c

    2162 static void nf_tables_expr_destroy(const struct nft_ctx *ctx,
    2163 				   struct nft_expr *expr)
    2164 {
    2165 	if (expr->ops->destroy)
    2166 		expr->ops->destroy(ctx, expr);
                                                ^^^^
--> 2167 	module_put(expr->ops->type->owner);
                           ^^^^^^^^^
    2168 }

Smatch says there are three functions which free expr->ops.

net/netfilter/nft_compat.c | nft_match_destroy 	     | 121 | PARAM_FREED | 1 | $->ops |
net/netfilter/nft_compat.c | nft_match_large_destroy | 124 | PARAM_FREED | 1 | $->ops |
net/netfilter/nft_compat.c | nft_target_destroy      | 56  | PARAM_FREED | 1 | $->ops |

regards,
dan carpenter