From pa4dan@Vitsch.net  Mon Aug  8 11:16:44 2005
Return-Path: <pa4dan@Vitsch.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D513916A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  8 Aug 2005 11:16:44 +0000 (GMT)
	(envelope-from pa4dan@Vitsch.net)
Received: from amsfep14-int.chello.nl (amsfep14-int.chello.nl [213.46.243.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 021B343D46
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  8 Aug 2005 11:16:43 +0000 (GMT)
	(envelope-from pa4dan@Vitsch.net)
Received: from Vitsch.net ([62.195.249.78]) by amsfep14-int.chello.nl
          (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP
          id <20050808111641.SIET28432.amsfep14-int.chello.nl@Vitsch.net>
          for <FreeBSD-gnats-submit@freebsd.org>;
          Mon, 8 Aug 2005 13:16:41 +0200
Received: (from pa4dan@localhost)
	by Vitsch.net (8.12.3p2/8.11.3) id j78BFhmY048923;
	Mon, 8 Aug 2005 13:15:43 +0200 (CEST)
	(envelope-from pa4dan)
Message-Id: <200508081115.j78BFhmY048923@Vitsch.net>
Date: Mon, 8 Aug 2005 13:15:43 +0200 (CEST)
From: "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>
Reply-To: "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: gctl_free() isn't called in fdisk.c
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         84664
>Category:       bin
>Synopsis:       [patch] gctl_free() isn't called in fdisk.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    rodrigc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 08 11:20:18 GMT 2005
>Closed-Date:    Wed Oct 05 01:17:39 GMT 2005
>Last-Modified:  Tue Oct 11 18:55:17 GMT 2005
>Originator:     Daan Vreeken [PA4DAN]
>Release:        FreeBSD 5.4-RELEASE i386
>Organization:
Vitsch Electronics
>Environment:
System: FreeBSD Racebeest.Vitsch.LAN 5.4-RELEASE FreeBSD 5.4-RELEASE #5: Sun Aug 7 19:58:10 CEST 2005 root@Racebeest.Vitsch.LAN:/usr/src/sys/i386/compile/Laptop i386


	
>Description:
	In the current version of fdisk.c gctl_get_handle() and gctl_issue()
are called in order to update the MBR of a disk without a corresponding call
to gctl_free().

>How-To-Repeat:
	n/a

>Fix:
	Apply the following patch to src/sbin/fdisk/fdisk.c :

--- fdisk.c.patch begins here ---
--- src/sbin/fdisk/fdisk.c.1_80	Mon Aug  8 13:05:02 2005
+++ src/sbin/fdisk/fdisk.c	Mon Aug  8 13:06:09 2005
@@ -761,6 +761,7 @@
 	gctl_ro_param(grq, "geom", -1, q);
 	gctl_ro_param(grq, "data", secsize, buf);
 	q = gctl_issue(grq);
+	gctl_free(grq);
 	if (q == NULL)
 		return(0);
 	warnx("%s", q);
--- fdisk.c.patch ends here ---



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->phk 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Thu Aug 11 11:17:43 GMT 2005 
Responsible-Changed-Why:  
Poul-Henning taught fdisk about GEOM. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=84664 
Responsible-Changed-From-To: phk->rodrigc 
Responsible-Changed-By: rodrigc 
Responsible-Changed-When: Fri Sep 2 18:07:10 GMT 2005 
Responsible-Changed-Why:  
Mine 

http://www.freebsd.org/cgi/query-pr.cgi?pr=84664 
--
Audit trail patch from replies misdirected to ports/84644:

From: Craig Rodrigues <rodrigc@crodrigues.org>
To: bug-followup@freebsd.org
Cc: Danovitsch@Vitsch.net
Subject: Re: bin/84644: [patch] gctl_free() isn't called in fdisk.c
Date: Fri, 2 Sep 2005 14:35:34 -0400

 Hi,
 
 Your patch isn't quite right.  If you
 look at the source code for gctl_issue(), the value
 of q can point to a string inside the grq struct,
 so you cannot free it if you are going to later on.
 
 Something like this is a bit better:
 
 Index: fdisk.c
 ===================================================================
 RCS file: /home/ncvs/src/sbin/fdisk/fdisk.c,v
 retrieving revision 1.80
 diff -u -u -r1.80 fdisk.c
 --- fdisk.c     15 Jul 2005 08:02:51 -0000      1.80
 +++ fdisk.c     2 Sep 2005 18:31:40 -0000
 @@ -761,9 +761,12 @@
         gctl_ro_param(grq, "geom", -1, q);
         gctl_ro_param(grq, "data", secsize, buf);
         q = gctl_issue(grq);
 -       if (q == NULL)
 +       if (q == NULL) {
 +               gctl_free(grq);
                 return(0);
 +       }
         warnx("%s", q);
 +       gctl_free(grq);
  
         error = pwrite(fd, buf, secsize, (sector * 512));
         if (error == secsize)
 
 -- 
 Craig Rodrigues        
 rodrigc@crodrigues.org

From: "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>
To: Craig Rodrigues <rodrigc@crodrigues.org>, Bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/84644: [patch] gctl_free() isn't called in fdisk.c
Date: Fri, 2 Sep 2005 22:59:06 +0200

 On Friday 02 September 2005 20:35, you wrote:
 > Hi,
 >
 > Your patch isn't quite right.  If you
 > look at the source code for gctl_issue(), the value
 > of q can point to a string inside the grq struct,
 > so you cannot free it if you are going to later on.
 >
 > Something like this is a bit better:
 [ ... snip ... ]
 
 Yes, that should be better :)
 
 grtz,
 Daan

end audit trail patch
--

State-Changed-From-To: open->closed 
State-Changed-By: rodrigc 
State-Changed-When: Wed Oct 5 01:17:09 GMT 2005 
State-Changed-Why:  
Patched in CURRENT and RELENG-6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=84664 
>Unformatted:
