From: Justin T. Gibbs Date: Thu, 2 Apr 2015 12:00:07 +0000 (+1100) Subject: Illumos 5592 - NULL pointer dereference in dsl_prop_notify_all_cb() X-Git-Tag: zfs-0.6.5~176 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6186e2975316e6693d576ab9eec8289c806e38a9;p=zfs Illumos 5592 - NULL pointer dereference in dsl_prop_notify_all_cb() 5592 NULL pointer dereference in dsl_prop_notify_all_cb() Author: Justin T. Gibbs Reviewed by: Dan McDonald Reviewed by: Matthew Ahrens Reviewed by: George Wilson Reviewed by: Will Andrews Approved by: Robert Mustacchi References: https://www.illumos.org/issues/5592 https://github.com/illumos/illumos-gate/commit/9d47dec Ported-by: Chris Dunlop Signed-off-by: Brian Behlendorf --- diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index a5310edce..de2703868 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -354,8 +354,19 @@ dsl_dataset_snap_remove(dsl_dataset_t *ds, const char *name, dmu_tx_t *tx, boolean_t dsl_dataset_try_add_ref(dsl_pool_t *dp, dsl_dataset_t *ds, void *tag) { - return (dmu_buf_try_add_ref(ds->ds_dbuf, dp->dp_meta_objset, - ds->ds_object, DMU_BONUS_BLKID, tag)); + dmu_buf_t *dbuf = ds->ds_dbuf; + boolean_t result = B_FALSE; + + if (dbuf != NULL && dmu_buf_try_add_ref(dbuf, dp->dp_meta_objset, + ds->ds_object, DMU_BONUS_BLKID, tag)) { + + if (ds == dmu_buf_get_user(dbuf)) + result = B_TRUE; + else + dmu_buf_rele(dbuf, tag); + } + + return (result); } int