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
GitHub <noreply@github.com>Committed on Sep 30 2022, 11:59 PM
Parents
rGa2d5643f88ce: Fix double const qualifier declarations
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rGa36b37d4de5d: Fix potential NULL pointer dereference in dsl_dataset_promote_check() (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Sep 30 2022, 11:59 PM