...
This compliant solution eliminates the null pointer deference by initializing sk
to tun->sk
following the null pointer check:. It also adds an assertion to document that a certain pointer must not be null.
Code Block | ||||
---|---|---|---|---|
| ||||
static unsigned int tun_chr_poll(struct file *file, poll_table *wait) {
assert(file);
struct tun_file *tfile = file->private_data;
struct tun_struct *tun = __tun_get(tfile);
struct sock *sk;
unsigned int mask = 0;
if (!tun)
return POLLERR;
sk = tun->sk;
/* The remaining code is omitted because it is unchanged... */
}
|
...