Commit 592ee43f authored by Colin Ian King's avatar Colin Ian King Committed by Alexei Starovoitov
Browse files

bpf: fix null pointer dereference on pointer offload



Pointer offload is being null checked however the following statement
dereferences the potentially null pointer offload when assigning
offload->dev_state.  Fix this by only assigning it if offload is not
null.

Detected by CoverityScan, CID#1475437 ("Dereference after null check")

Fixes: 00db12c3 ("bpf: call verifier_prep from its callback in struct bpf_offload_dev")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 29a9c10e
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -130,9 +130,10 @@ int bpf_prog_offload_verifier_prep(struct bpf_prog *prog)

	down_read(&bpf_devs_lock);
	offload = prog->aux->offload;
	if (offload)
	if (offload) {
		ret = offload->offdev->ops->prepare(prog);
		offload->dev_state = !ret;
	}
	up_read(&bpf_devs_lock);

	return ret;