From 12b859c97079f6aa82aba7a63b47353c1d464d38 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Fri, 16 Sep 2022 17:02:54 -0400 Subject: [PATCH] Fix null pointer dereferences in PAM Coverity caught these. Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Closes #13889 --- contrib/pam_zfs_key/pam_zfs_key.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/pam_zfs_key/pam_zfs_key.c b/contrib/pam_zfs_key/pam_zfs_key.c index 0856c7534f..703d0ad57f 100644 --- a/contrib/pam_zfs_key/pam_zfs_key.c +++ b/contrib/pam_zfs_key/pam_zfs_key.c @@ -496,7 +496,6 @@ zfs_key_config_get_dataset(zfs_key_config_t *config) if (zhp == NULL) { pam_syslog(NULL, LOG_ERR, "dataset %s not found", config->homes_prefix); - zfs_close(zhp); return (NULL); } @@ -508,6 +507,10 @@ zfs_key_config_get_dataset(zfs_key_config_t *config) return (dsname); } + if (config->homes_prefix == NULL) { + return (NULL); + } + size_t len = ZFS_MAX_DATASET_NAME_LEN; size_t total_len = strlen(config->homes_prefix) + 1 + strlen(config->username);