aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2021-05-21 14:55:07 +0000
committerKristof Provost <kp@FreeBSD.org>2021-06-17 14:53:36 +0000
commit719f6456fbdee54f94109f945d7d945b2abf9589 (patch)
tree42c87124164b97ef124d90bdd42a9424ff2f6017
parentbc90a9cb0a741315ed6a43807b781acd2bd0957c (diff)
downloadsrc-719f6456fbdee54f94109f945d7d945b2abf9589.tar.gz
src-719f6456fbdee54f94109f945d7d945b2abf9589.zip
dummynet: free(NULL, M_DUMMYNET); is safe
There's no need to check pointers for NULL before free()ing them. No functional change. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D30382 (cherry picked from commit 1b2dbe37fa32d7255faf7d1feec7bb31414a8102)
-rw-r--r--sys/netpfil/ipfw/ip_dummynet.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c
index c412a45f7296..57565e0d7d23 100644
--- a/sys/netpfil/ipfw/ip_dummynet.c
+++ b/sys/netpfil/ipfw/ip_dummynet.c
@@ -758,8 +758,7 @@ fsk_detach(struct dn_fsk *fs, int flags)
/* Free the RED parameters, they will be recomputed on
* subsequent attach if needed.
*/
- if (fs->w_q_lookup)
- free(fs->w_q_lookup, M_DUMMYNET);
+ free(fs->w_q_lookup, M_DUMMYNET);
fs->w_q_lookup = NULL;
qht_delete(fs, flags);
#ifdef NEW_AQM
@@ -911,10 +910,9 @@ schk_delete_cb(void *obj, void *arg)
dn_ht_free(s->siht, 0);
} else if (s->siht)
si_destroy(s->siht, NULL);
- if (s->profile) {
- free(s->profile, M_DUMMYNET);
- s->profile = NULL;
- }
+
+ free(s->profile, M_DUMMYNET);
+ s->profile = NULL;
s->siht = NULL;
if (s->fp->destroy)
s->fp->destroy(s);
@@ -1238,10 +1236,8 @@ config_red(struct dn_fsk *fs)
}
/* If the lookup table already exist, free and create it again. */
- if (fs->w_q_lookup) {
- free(fs->w_q_lookup, M_DUMMYNET);
- fs->w_q_lookup = NULL;
- }
+ free(fs->w_q_lookup, M_DUMMYNET);
+ fs->w_q_lookup = NULL;
if (V_dn_cfg.red_lookup_depth == 0) {
printf("\ndummynet: net.inet.ip.dummynet.red_lookup_depth"
"must be > 0\n");
@@ -1580,10 +1576,9 @@ config_link(struct dn_link *p, struct dn_id *arg)
return EINVAL;
}
/* remove profile if exists */
- if (s->profile) {
- free(s->profile, M_DUMMYNET);
- s->profile = NULL;
- }
+ free(s->profile, M_DUMMYNET);
+ s->profile = NULL;
+
/* copy all parameters */
s->link.oid = p->oid;
s->link.link_nr = i;
@@ -1707,8 +1702,7 @@ config_fs(struct dn_fs *nfs, struct dn_id *arg, int locked)
if (!locked)
DN_BH_WUNLOCK();
#ifdef NEW_AQM
- if (ep != NULL)
- free(ep, M_TEMP);
+ free(ep, M_TEMP);
#endif
return fs;
}
@@ -1907,8 +1901,7 @@ next:
err = 0;
error:
DN_BH_WUNLOCK();
- if (pf)
- free(pf, M_DUMMYNET);
+ free(pf, M_DUMMYNET);
return err;
}
@@ -2136,10 +2129,8 @@ do_config(void *p, int l)
break;
off += o.len;
}
- if (arg != NULL)
- free(arg, M_TEMP);
- if (dn != NULL)
- free(dn, M_TEMP);
+ free(arg, M_TEMP);
+ free(dn, M_TEMP);
return err;
}
@@ -2325,8 +2316,7 @@ dummynet_get(struct sockopt *sopt, void **compat)
break;
DN_BH_WUNLOCK();
- if (start)
- free(start, M_DUMMYNET);
+ free(start, M_DUMMYNET);
start = NULL;
if (need > sopt_valsize)
break;
@@ -2384,10 +2374,9 @@ dummynet_get(struct sockopt *sopt, void **compat)
error = sooptcopyout(sopt, start, buf - start);
}
done:
- if (cmd && cmd != &r.o)
+ if (cmd != &r.o)
free(cmd, M_DUMMYNET);
- if (start)
- free(start, M_DUMMYNET);
+ free(start, M_DUMMYNET);
return error;
}
@@ -2548,8 +2537,7 @@ ip_dn_ctl(struct sockopt *sopt)
break;
}
- if (p != NULL)
- free(p, M_TEMP);
+ free(p, M_TEMP);
NET_EPOCH_EXIT_ET(et);