Mon Mar 9 15:40:50 2020 UTC ()
external/cddl/osnet: Fix possible null pointer access.

Detected by UBSan and fixed upstream, pick only the fix from the commit.

Cherry-pick:
From 928e8ad47d3478a3d5d01f0dd6ae74a9371af65e Mon Sep 17 00:00:00 2001
From: Serapheim Dimitropoulos <serapheimd@gmail.com>
Date: Wed, 20 Feb 2019 09:59:57 -0800
Subject: [PATCH] Introduce auxiliary metaslab histograms

Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #8358

Reviewed by: kamil@


(fox)
diff -r1.1.1.3 -r1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c

cvs diff -r1.1.1.3 -r1.2 src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c (expand / switch to unified diff)

--- src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c 2018/05/28 20:52:58 1.1.1.3
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/metaslab.c 2020/03/09 15:40:50 1.2
@@ -3360,27 +3360,27 @@ metaslab_class_throttle_unreserve(metasl @@ -3360,27 +3360,27 @@ metaslab_class_throttle_unreserve(metasl
3360 mutex_enter(&mc->mc_lock); 3360 mutex_enter(&mc->mc_lock);
3361 for (int d = 0; d < slots; d++) { 3361 for (int d = 0; d < slots; d++) {
3362 (void) refcount_remove(&mc->mc_alloc_slots, zio); 3362 (void) refcount_remove(&mc->mc_alloc_slots, zio);
3363 } 3363 }
3364 mutex_exit(&mc->mc_lock); 3364 mutex_exit(&mc->mc_lock);
3365} 3365}
3366 3366
3367int 3367int
3368metaslab_alloc(spa_t *spa, metaslab_class_t *mc, uint64_t psize, blkptr_t *bp, 3368metaslab_alloc(spa_t *spa, metaslab_class_t *mc, uint64_t psize, blkptr_t *bp,
3369 int ndvas, uint64_t txg, blkptr_t *hintbp, int flags, 3369 int ndvas, uint64_t txg, blkptr_t *hintbp, int flags,
3370 zio_alloc_list_t *zal, zio_t *zio) 3370 zio_alloc_list_t *zal, zio_t *zio)
3371{ 3371{
3372 dva_t *dva = bp->blk_dva; 3372 dva_t *dva = bp->blk_dva;
3373 dva_t *hintdva = hintbp->blk_dva; 3373 dva_t *hintdva = (hintbp != NULL) ? hintbp->blk_dva : NULL;
3374 int error = 0; 3374 int error = 0;
3375 3375
3376 ASSERT(bp->blk_birth == 0); 3376 ASSERT(bp->blk_birth == 0);
3377 ASSERT(BP_PHYSICAL_BIRTH(bp) == 0); 3377 ASSERT(BP_PHYSICAL_BIRTH(bp) == 0);
3378 3378
3379 spa_config_enter(spa, SCL_ALLOC, FTAG, RW_READER); 3379 spa_config_enter(spa, SCL_ALLOC, FTAG, RW_READER);
3380 3380
3381 if (mc->mc_rotor == NULL) { /* no vdevs in this class */ 3381 if (mc->mc_rotor == NULL) { /* no vdevs in this class */
3382 spa_config_exit(spa, SCL_ALLOC, FTAG); 3382 spa_config_exit(spa, SCL_ALLOC, FTAG);
3383 return (SET_ERROR(ENOSPC)); 3383 return (SET_ERROR(ENOSPC));
3384 } 3384 }
3385 3385
3386 ASSERT(ndvas > 0 && ndvas <= spa_max_replication(spa)); 3386 ASSERT(ndvas > 0 && ndvas <= spa_max_replication(spa));