From d9de85e5aa4a1241264ea9f89a866de7149f2b93 Mon Sep 17 00:00:00 2001 From: ken Date: Sun, 12 Sep 1999 19:40:20 +0000 Subject: Fix a file descriptor leak in cam_open_btl(). The xpt device was opened, but never closed. Submitted by: amobbs@allstor-sw.co.uk --- lib/libcam/camlib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c index 5f2152d..648b030 100644 --- a/lib/libcam/camlib.c +++ b/lib/libcam/camlib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998 Kenneth D. Merry. + * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -357,6 +357,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun, if (ccb.cdm.matches == NULL) { snprintf(cam_errbuf, CAM_ERRBUF_SIZE, "%s: couldn't malloc match buffer", func_name); + close(fd); return(NULL); } ccb.cdm.num_matches = 0; @@ -370,6 +371,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); + close(fd); return(NULL); } ccb.cdm.patterns[0].type = DEV_MATCH_PERIPH; @@ -429,6 +431,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun, pass_unit = periph_result->unit_number; free(ccb.cdm.matches); free(ccb.cdm.patterns); + close(fd); sprintf(dev_path, "/dev/pass%d", pass_unit); return(cam_real_open_device(dev_path, flags, device, NULL, NULL, 0)); @@ -444,6 +447,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun, btl_bailout: free(ccb.cdm.matches); free(ccb.cdm.patterns); + close(fd); return(NULL); } -- cgit v1.1