aboutsummaryrefslogtreecommitdiff
path: root/lib/libcam
diff options
context:
space:
mode:
authorKenneth D. Merry <ken@FreeBSD.org>1999-09-12 19:40:20 +0000
committerKenneth D. Merry <ken@FreeBSD.org>1999-09-12 19:40:20 +0000
commit661d7edf84ea036f54a2dd76026cae6bcba7f326 (patch)
treee1ac73e4b8f4c97fbd5bb555cb4867bae4312b77 /lib/libcam
parent32952d4b37e2af9ee818481aff41144e05fa74ae (diff)
downloadsrc-661d7edf84ea036f54a2dd76026cae6bcba7f326.tar.gz
src-661d7edf84ea036f54a2dd76026cae6bcba7f326.zip
Fix a file descriptor leak in cam_open_btl(). The xpt device was opened,
but never closed. Submitted by: amobbs@allstor-sw.co.uk
Notes
Notes: svn path=/head/; revision=51213
Diffstat (limited to 'lib/libcam')
-rw-r--r--lib/libcam/camlib.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c
index 5f2152dab833..648b0303a96c 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);
}