Skip to content

Commit

Permalink
Prevent NULL pointer dereference in blkg_tryget() on EL8 kernels
Browse files Browse the repository at this point in the history
blkg_tryget() as shipped in EL8 kernels does not seem to handle NULL
@blkg as input; this is different from its mainline counterpart where
NULL is accepted.  To prevent dereferencing a NULL pointer when dealing
with block devices which do not set a root_blkg on the request queue
perform the NULL check in vdev_bio_associate_blkg().

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #9546
Closes #9577
  • Loading branch information
loli10K authored and tonyhutter committed Jan 22, 2020
1 parent 1545f7c commit 880a37a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion module/zfs/vdev_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ vdev_bio_associate_blkg(struct bio *bio)
ASSERT3P(q, !=, NULL);
ASSERT3P(bio->bi_blkg, ==, NULL);

if (blkg_tryget(q->root_blkg))
if (q->root_blkg && blkg_tryget(q->root_blkg))
bio->bi_blkg = q->root_blkg;
}
#define bio_associate_blkg vdev_bio_associate_blkg
Expand Down

0 comments on commit 880a37a

Please sign in to comment.