Date: Mon, 14 Apr 2014 00:46:33 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Christian Brueffer <brueffer@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r264422 - head/sys/kern Message-ID: <20140413214633.GF4016@kib.kiev.ua> In-Reply-To: <201404132123.s3DLNGvJ048359@svn.freebsd.org> References: <201404132123.s3DLNGvJ048359@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--0/kgSOzhNoDC5T3a Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Apr 13, 2014 at 09:23:16PM +0000, Christian Brueffer wrote: > Author: brueffer > Date: Sun Apr 13 21:23:15 2014 > New Revision: 264422 > URL: http://svnweb.freebsd.org/changeset/base/264422 >=20 > Log: > Free buf after usage. > =20 > CID: 1199377 > Found with: Coverity Prevent(tm) > MFC after: 1 week >=20 > Modified: > head/sys/kern/imgact_elf.c >=20 > Modified: head/sys/kern/imgact_elf.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/kern/imgact_elf.c Sun Apr 13 21:13:33 2014 (r264421) > +++ head/sys/kern/imgact_elf.c Sun Apr 13 21:23:15 2014 (r264422) > @@ -1746,8 +1746,10 @@ __elfN(note_threadmd)(void *arg, struct=20 > size =3D 0; > __elfN(dump_thread)(td, buf, &size); > KASSERT(*sizep =3D=3D size, ("invalid size")); > - if (size !=3D 0 && sb !=3D NULL) > + if (size !=3D 0 && sb !=3D NULL) { > sbuf_bcat(sb, buf, size); > + free(buf, M_TEMP); > + } > *sizep =3D size; > } > =20 Why conditioning free() on size !=3D 0 ? IMO free(buf) must be done always, since buf is initialized for the case when malloc() is not called. --0/kgSOzhNoDC5T3a Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJTSwW5AAoJEJDCuSvBvK1BNy4P/RAs067+LZWgR0hysHK+PFWd AK8yX48NLHYt9iWbJH5QKVyN68VuFHjy4F+yWa0aiJwHH1mJ3OMjQnJurxsz7t+Z HNjcf5yk1E0+So1WZDOcYfCyIPGSa6Ns/B/YaQolYa53zabWuXvnqmK4iDhJjanV 3O/A7zix1dE3NHdedchN61Hf/ptrzw3wPmYpz9ozHvS+20uQh2SODR8wmKq5Y3iZ NZR/DY08Zc3pGYI3IdKTJaRs9fKGkQi7nUeoIj/g/cdPcblygbqkTauMRYiaxOVY 8dzj8cH3U73TVxcWez0PHW2yTofyiN2diKPuV+rw1JRrSknAdkdCDP9qFrrqm0v9 hK++4+dW5cjVnJRa2ZNig4xT1KKzNP4pN7R3F2tCGpDwqcnPGJizkf1fO5KSrxuw 38AHPgkfQbLpj/HXCCT6HDPfGF4w0z65sL8NliXoFYqzc+4qSgSp2AcDzX/gWuU+ RiKXjw6nji8Eqv3p3ZtM5qPE4i9jr9quz2St6xwmlg6cAsJc+UOerzYSueqSOwli NyxekdnHZz1a9+T2x3FdWFZU0AApVzEeHA+XR5fMt+stt5AnT78moG69hRodj7t1 4iabz/AYsaG2JpUle+M8SYlpgpIK/wKRsc9rNC70jnEwErwOfP9u4HFX/17i0jTs stf5+MaT6IO7F5Us4GJ3 =WbpZ -----END PGP SIGNATURE----- --0/kgSOzhNoDC5T3a--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140413214633.GF4016>