@@ -779,7 +779,7 @@ ctnetlink_alloc_filter(const struct nlattr * const cda[])
struct ctnetlink_filter *filter;
filter = kzalloc(sizeof(*filter), GFP_KERNEL);
- if (filter == NULL)
+ if (!filter)
return ERR_PTR(-ENOMEM);
filter->mark.val = ntohl(nla_get_be32(cda[CTA_MARK]));
@@ -358,7 +358,7 @@ int nf_ct_l4proto_register_one(struct nf_conntrack_l4proto *l4proto)
proto_array = kmalloc(MAX_NF_CT_PROTO *
sizeof(struct nf_conntrack_l4proto *),
GFP_KERNEL);
- if (proto_array == NULL) {
+ if (!proto_array) {
ret = -ENOMEM;
goto out_unlock;
}
@@ -626,7 +626,7 @@ int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto)
if (nf_nat_l4protos[l3proto] == NULL) {
l4protos = kmalloc(IPPROTO_MAX * sizeof(struct nf_nat_l4proto *),
GFP_KERNEL);
- if (l4protos == NULL) {
+ if (!l4protos) {
ret = -ENOMEM;
goto out;
}
Some functions like kmalloc/kzalloc return NULL on failure. When NULL represents failure, !x is commonly used. This was done using Coccinelle: @@ expression *e; identifier l1; @@ e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...); ... - e == NULL + !e Signed-off-by: simran singhal <singhalsimran0@gmail.com> --- --This is my contribution to the netfilter project of Outreachy Round 14. net/netfilter/nf_conntrack_netlink.c | 2 +- net/netfilter/nf_conntrack_proto.c | 2 +- net/netfilter/nf_nat_core.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)