Fix a memory leak for the BIOCSETWF ioctl on kernels with the BPF_JITTER

option.

The BPF code was creating a compiled filter in the common filter-creation
path.  However, BPF only uses compiled filters in the read direction.
When creating a write filter, the common filter-creation code was
creating an unneeded write filter and leaking the memory used for that.

MFC after:	2 weeks
Sponsored by:	Netflix
This commit is contained in:
Jonathan T. Looney 2018-06-11 23:32:06 +00:00
parent b5e2ff92e5
commit 16a227c7c9

View File

@ -1895,8 +1895,13 @@ bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_long cmd)
return (EINVAL);
}
#ifdef BPF_JITTER
/* Filter is copied inside fcode and is perfectly valid. */
jfunc = bpf_jitter(fcode, flen);
if (cmd != BIOCSETWF) {
/*
* Filter is copied inside fcode and is
* perfectly valid.
*/
jfunc = bpf_jitter(fcode, flen);
}
#endif
}