Bug 28688

Summary: [PATCH] camlib.c: cam_real_open_device fd leak
Product: Base System Reporter: bill <bill>
Component: binAssignee: Matt Jacob <mjacob>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description bill 2001-07-04 08:30:07 UTC
	When one of the various system calls in
	cam_real_open_device fails after the open, the file
	descriptor is left open.

Fix: Apply the following patch:

/*
	 * See if the user wants us to malloc a device for him.
--- 554,560 ----
	char newpath[MAXPATHLEN+1];
	char *func_name = "cam_real_open_device";
	union ccb ccb;
!       int fd = -1, malloced_device = 0;

	/*
	 * See if the user wants us to malloc a device for him.
***************


crod_bailout:

+       if (fd >= 0) {
+               close(fd);
+       }
	if (malloced_device)
		free(device);--InI4C6aPnNYjp47dxBi7HDBqSxkAwm10KGELD6WOWIirzl2h
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

*** camlib.c.orig       Wed Jul  4 02:42:31 2001
--- camlib.c    Wed Jul  4 02:43:50 2001
***************
*** 554,560 ****
	char newpath[MAXPATHLEN+1];
	char *func_name = "cam_real_open_device";
	union ccb ccb;
!       int fd, malloced_device = 0;
How-To-Repeat: 	Open a non-SCSI device (e.g., /dev/scanner attached to a
	USB device) and the device will be left open, causing
	subsequent open attempts to fail. This was observed to
	happen in SANE's scanimage.
Comment 1 Matt Jacob freebsd_committer freebsd_triage 2001-07-04 08:31:35 UTC
Responsible Changed
From-To: freebsd-bugs->mjacob

I'll field it
Comment 2 Matt Jacob freebsd_committer freebsd_triage 2001-07-25 00:09:18 UTC
State Changed
From-To: open->closed

Fixed in -current ant RELENG_4.