dmu_tx: Fix possible NULL pointer dereference

dmu_tx_hold_object_impl can return NULL on error.  Check for this
condition prior to dereferencing pointer.  This can only occur if
the passed object was invalid or unallocated.

Signed-off-by: Nathaniel Clark <Nathaniel.Clark@misrule.us>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1610
This commit is contained in:
Nathaniel Clark 2013-07-23 13:32:57 -04:00 committed by Brian Behlendorf
parent cb543e6b5e
commit 7d63721118

View File

@ -773,11 +773,12 @@ void
dmu_tx_hold_space(dmu_tx_t *tx, uint64_t space) dmu_tx_hold_space(dmu_tx_t *tx, uint64_t space)
{ {
dmu_tx_hold_t *txh; dmu_tx_hold_t *txh;
ASSERT(tx->tx_txg == 0); ASSERT(tx->tx_txg == 0);
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, txh = dmu_tx_hold_object_impl(tx, tx->tx_objset,
DMU_NEW_OBJECT, THT_SPACE, space, 0); DMU_NEW_OBJECT, THT_SPACE, space, 0);
if (txh)
txh->txh_space_towrite += space; txh->txh_space_towrite += space;
} }
@ -1320,6 +1321,8 @@ dmu_tx_hold_spill(dmu_tx_t *tx, uint64_t object)
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, object, txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, object,
THT_SPILL, 0, 0); THT_SPILL, 0, 0);
if (txh == NULL)
return;
dn = txh->txh_dnode; dn = txh->txh_dnode;