diff options
author | ngie <ngie@FreeBSD.org> | 2017-03-27 18:29:30 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-03-27 18:29:30 +0000 |
commit | 23887fe54ba3fc2c92c876e60ad1110c9786c266 (patch) | |
tree | 7e601f1d42e2cee0c040421078db6c4a581d52a0 /lib | |
parent | b2b2e61185cafd129dcfd8ff9386cf8c80c085db (diff) | |
download | FreeBSD-src-23887fe54ba3fc2c92c876e60ad1110c9786c266.zip FreeBSD-src-23887fe54ba3fc2c92c876e60ad1110c9786c266.tar.gz |
MFC r315639:
libcam: NULL out freed `ccb.cdm.matches` and `ccb.cdm.patterns` pointers
This is being done to avoid potential double frees with the values.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcam/camlib.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c index 7aac240..89736e2 100644 --- a/lib/libcam/camlib.c +++ b/lib/libcam/camlib.c @@ -308,6 +308,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun, snprintf(cam_errbuf, CAM_ERRBUF_SIZE, "%s: couldn't malloc pattern buffer", func_name); free(ccb.cdm.matches); + ccb.cdm.matches = NULL; close(fd); return(NULL); } @@ -371,7 +372,9 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun, periph_result = &ccb.cdm.matches[0].result.periph_result; pass_unit = periph_result->unit_number; free(ccb.cdm.matches); + ccb.cdm.matches = NULL; free(ccb.cdm.patterns); + ccb.cdm.patterns = NULL; close(fd); sprintf(dev_path, "/dev/pass%d", pass_unit); return(cam_real_open_device(dev_path, flags, device, NULL, @@ -388,7 +391,9 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun, btl_bailout: free(ccb.cdm.matches); + ccb.cdm.matches = NULL; free(ccb.cdm.patterns); + ccb.cdm.patterns = NULL; close(fd); return(NULL); } |