Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Jul 2001 03:25:54 -0400
From:      "T. William Wells" <bill@twwells.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/28688: [PATCH] camlib.c: cam_real_open_device fd leak
Message-ID:  <E15Hh2o-000BfA-00@twwells.com>

next in thread | raw e-mail | index | archive | help

>Number:         28688
>Category:       bin
>Synopsis:       [PATCH] camlib.c: cam_real_open_device fd leak
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 04 00:30:07 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     T. William Wells
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
>Environment:
System: FreeBSD twwells.com 4.3-STABLE FreeBSD 4.3-STABLE #7: Fri May 18 01:15:21 EDT 2001 root@twwells.com:/usr/obj/usr/src/sys/TWWELLS i386


	
>Description:
	When one of the various system calls in
	cam_real_open_device fails after the open, the file
	descriptor is left open.

>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.
>Fix:

Apply the following patch:

*** 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;

	/*
	 * 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.
***************
*** 691,696 ****
--- 691,699 ----

  crod_bailout:

+       if (fd >= 0) {
+               close(fd);
+       }
	if (malloced_device)
		free(device);

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E15Hh2o-000BfA-00>