diff options
author | Isaac Huang <[email protected]> | 2014-03-03 20:00:11 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2014-08-20 10:45:16 -0700 |
commit | 0426c16804e572f088dd293029ab39fa75e1e203 (patch) | |
tree | 0285b5718f4d72a8e69d54c73be0e11b37a253a6 /module/zfs/zfs_fm.c | |
parent | bd089c547784a4ab23fa20f307e8b23b0a622525 (diff) |
Fixed memory leaks in zevent handling
Some nvlist_t could be leaked in error handling paths.
Also make sure cb argument to zfs_zevent_post() cannnot
be NULL.
Signed-off-by: Isaac Huang <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #2158
Diffstat (limited to 'module/zfs/zfs_fm.c')
-rw-r--r-- | module/zfs/zfs_fm.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/module/zfs/zfs_fm.c b/module/zfs/zfs_fm.c index 05ee84c19..fb65ec6a6 100644 --- a/module/zfs/zfs_fm.c +++ b/module/zfs/zfs_fm.c @@ -113,6 +113,11 @@ zfs_zevent_post_cb(nvlist_t *nvl, nvlist_t *detector) } static void +zfs_zevent_post_cb_noop(nvlist_t *nvl, nvlist_t *detector) +{ +} + +static void zfs_ereport_start(nvlist_t **ereport_out, nvlist_t **detector_out, const char *subclass, spa_t *spa, vdev_t *vd, zio_t *zio, uint64_t stateoroffset, uint64_t size) @@ -768,12 +773,7 @@ zfs_ereport_start_checksum(spa_t *spa, vdev_t *vd, FM_EREPORT_ZFS_CHECKSUM, spa, vd, zio, offset, length); if (report->zcr_ereport == NULL) { - report->zcr_free(report->zcr_cbdata, report->zcr_cbinfo); - if (report->zcr_ckinfo != NULL) { - kmem_free(report->zcr_ckinfo, - sizeof (*report->zcr_ckinfo)); - } - kmem_free(report, sizeof (*report)); + zfs_ereport_free_checksum(report); return; } #endif @@ -789,13 +789,15 @@ zfs_ereport_finish_checksum(zio_cksum_report_t *report, const void *good_data, const void *bad_data, boolean_t drop_if_identical) { #ifdef _KERNEL - zfs_ecksum_info_t *info = NULL; + zfs_ecksum_info_t *info; + info = annotate_ecksum(report->zcr_ereport, report->zcr_ckinfo, good_data, bad_data, report->zcr_length, drop_if_identical); - if (info != NULL) zfs_zevent_post(report->zcr_ereport, report->zcr_detector, zfs_zevent_post_cb); + else + zfs_zevent_post_cb(report->zcr_ereport, report->zcr_detector); report->zcr_ereport = report->zcr_detector = NULL; if (info != NULL) @@ -826,7 +828,8 @@ void zfs_ereport_send_interim_checksum(zio_cksum_report_t *report) { #ifdef _KERNEL - zfs_zevent_post(report->zcr_ereport, report->zcr_detector, NULL); + zfs_zevent_post(report->zcr_ereport, report->zcr_detector, + zfs_zevent_post_cb_noop); #endif } |