Skip to content

Commit

Permalink
Fix crash in zio_done error reporting
Browse files Browse the repository at this point in the history
Fix NULL pointer dereference when reporting
checksum error for gang block in zio_done.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Zuchowski <pzuchowski@datto.com>
Closes #11872
Closes #11896
  • Loading branch information
PaulZ-98 authored and behlendorf committed May 20, 2021
1 parent e2a3296 commit b996523
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Copyright (c) 2017, Intel Corporation.
* Copyright (c) 2019, Klara Inc.
* Copyright (c) 2019, Allan Jude
* Copyright (c) 2021, Datto, Inc.
*/

#include <sys/sysmacros.h>
Expand Down Expand Up @@ -4499,7 +4500,7 @@ zio_done(zio_t *zio)
uint64_t asize = P2ROUNDUP(psize, align);
abd_t *adata = zio->io_abd;

if (asize != psize) {
if (adata != NULL && asize != psize) {
adata = abd_alloc(asize, B_TRUE);
abd_copy(adata, zio->io_abd, psize);
abd_zero_off(adata, psize, asize - psize);
Expand All @@ -4510,7 +4511,7 @@ zio_done(zio_t *zio)
zcr->zcr_finish(zcr, adata);
zfs_ereport_free_checksum(zcr);

if (asize != psize)
if (adata != NULL && asize != psize)
abd_free(adata);
}
}
Expand Down

0 comments on commit b996523

Please sign in to comment.