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