HomeFreeBSD

Fix potential NULL pointer dereference in dsl_dataset_promote_check()

Description

Fix potential NULL pointer dereference in dsl_dataset_promote_check()

If the list_head() returns NULL, we dereference it, right before we
check to see if it returned NULL.

We have defined two different pointers that both point to the same
thing, which are origin_head and origin_ds. Almost everything uses
origin_ds, so we switch them to use origin_ds.

We also promote origin_ds to a const pointer so that the compiler
verifies that nothing modifies it.

Coverity complained about this.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13967

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Sep 30 2022, 11:59 PM
Tony Hutter <hutter2@llnl.gov>Committed on Dec 1 2022, 8:39 PM
Parents
rGd4df36de5da0: Fix unreachable code in zstreamdump
Branches
Unknown
Tags
Unknown

Event Timeline

Tony Hutter <hutter2@llnl.gov> committed rGc562bbefc00f: Fix potential NULL pointer dereference in dsl_dataset_promote_check() (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Dec 1 2022, 8:39 PM