From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Q3bug-0006ZN-0z for mharc-grub-devel@gnu.org; Sat, 26 Mar 2011 18:24:54 -0400 Received: from [140.186.70.92] (port=44809 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q3buZ-0006SE-Ay for grub-devel@gnu.org; Sat, 26 Mar 2011 18:24:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q3buT-0000Xg-0c for grub-devel@gnu.org; Sat, 26 Mar 2011 18:24:42 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:49760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q3buS-0000Xa-On for grub-devel@gnu.org; Sat, 26 Mar 2011 18:24:40 -0400 Received: by wyf19 with SMTP id 19so2287076wyf.0 for ; Sat, 26 Mar 2011 15:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type; bh=FNj95xo2ZPvaLryXDXtEWS6AaHbDmCVdO60A2uhCMiA=; b=ZRJynnHBqNTw6r+bRlnlcV6KPhtaJqOVP8Ro/DscWIjhRFH2Vk0m8X/TtfT/EXjX44 Zs+ZFgYN5IKMQ0ts6HakjwKwjuWJQOZZcyQ2KQOghkkvthTgV5bNl5DCO9TeoJIxn27C OuG1AHyfoul9oXVegG8pJSFYFkrKtFxe0RtAg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=B6ZItEJAxmdbyZtbWUuwkM8tpwzHGkANPqWGjYZxx6MrrRbx5+5m1qFvi6umTNJZMP 2dd2BuCgAiyBFgyJMlB1i3p59CP5nCNqLTfTQbyD/PkwqgXYsQsVAwwpB/cXqNpWt+kc LP2VXgV1YLElbjAuaCyp510Y3NBW5ORNAnK4E= Received: by 10.227.195.143 with SMTP id ec15mr2275478wbb.213.1301178279538; Sat, 26 Mar 2011 15:24:39 -0700 (PDT) Received: from debian.x201.phnet (106-74.203-62.cust.bluewin.ch [62.203.74.106]) by mx.google.com with ESMTPS id g7sm1173597wby.31.2011.03.26.15.24.36 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 Mar 2011 15:24:37 -0700 (PDT) Message-ID: <4D8E67A3.9040508@gmail.com> Date: Sat, 26 Mar 2011 23:24:35 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110303 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 To: grub-devel@gnu.org References: In-Reply-To: X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig4B76E76577C2057F06227888" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.169 Subject: Re: Patch for getroot.c X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Mar 2011 22:24:51 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig4B76E76577C2057F06227888 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11.02.2011 20:58, Seth Goldberg wrote: > Hi, > > When testing with UMEM_DEBUG set to default on Solaris, I discovered > that find_root_device_from_libzfs() was maintaining a pointer to state > that was freed when zpool_close() was called (specifically, the device > path string, retrieved from an nvlist). The path here fixes that and > make this function a bit more bulletproof by testing for NULLs. (Note > that this returns memory that is not freed by the util programs that > use it, but that's not unique to this patch -- all strings from > grub_guess_root_device() aren't freed after they're used.) > Applied with some changes. Patch for the parts we don't have is obviously skipped > =3D=3D=3D modified file 'grub-core/kern/emu/getroot.c' > --- grub-core/kern/emu/getroot.c 2011-01-12 02:57:53 +0000 > +++ grub-core/kern/emu/getroot.c 2011-02-11 19:48:23 +0000 > @@ -185,7 +185,7 @@ > static char * > find_root_device_from_libzfs (const char *dir, struct stat *sbp) > { > - char *device; > + char *device =3D NULL; > char *poolname; > char *poolfs; > > @@ -224,9 +224,13 @@ > if (nvlist_lookup_string (children[i], "path", &device) !=3D 0) > error (1, errno, "nvlist_lookup_string (\"path\")"); > > + grub_dprintf("zfs", "device -> %s\n", device); > + > struct stat st; > - if (stat (device, &st) =3D=3D 0) > + if (stat (device, &st) =3D=3D 0) { > + device =3D grub_strdup(device); > break; > + } > > device =3D NULL; > } > @@ -240,12 +244,15 @@ > > #if defined(__sun__) > /* If the device is a /dev/dsk path, convert it into a /dev/rdsk > one */ > - if (strncmp(device, "/dev/dsk/", 9) =3D=3D 0) { > - device =3D xasprintf("/dev/rdsk/%s", device + 9); > + if (device !=3D NULL && strncmp(device, "/dev/dsk/", 9) =3D=3D 0) { > + char *newdevice =3D xasprintf("/dev/rdsk/%s", device + 9); > + grub_free(device); > + device =3D newdevice; > } > #endif > > - grub_util_info("zfs path =3D %s", device); > + if (device !=3D NULL) > + grub_util_info("zfs path =3D %s", device); > > return device; > } > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------enig4B76E76577C2057F06227888 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAk2OZ6MACgkQNak7dOguQgmy5AD9GEMBsvmaIbD/cPoWQEODrEFY pqKnb08JXhT8l2++sdIBALOJ39A4sOo191WRD2xFa1mlXJ+xKGJwi899sFrwV8w6 =llrG -----END PGP SIGNATURE----- --------------enig4B76E76577C2057F06227888--