Date: Sun, 13 Apr 2014 23:55:54 +0200 From: Christian Brueffer <brueffer@FreeBSD.org> To: Konstantin Belousov <kostikbel@gmail.com> 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: <534B07EA.7080400@FreeBSD.org> In-Reply-To: <20140413214633.GF4016@kib.kiev.ua> References: <201404132123.s3DLNGvJ048359@svn.freebsd.org> <20140413214633.GF4016@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1GN7UObGkwVAwht6FBC0rn66egmRIsVe4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 4/13/14 11:46 PM, Konstantin Belousov wrote: > 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 >> >> Log: >> Free buf after usage. >> =20 >> CID: 1199377 >> Found with: Coverity Prevent(tm) >> MFC after: 1 week >> >> Modified: >> head/sys/kern/imgact_elf.c >> >> 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 cas= e > when malloc() is not called. >=20 The corresponding malloc() call is behind a similar conditional, so it seemed good to be symmetrical here (since buf if NULL otherwise anyway). I can change it to call free() unconditionally if you prefer, I don't mind either way. Chris --1GN7UObGkwVAwht6FBC0rn66egmRIsVe4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQJ8BAEBCgBmBQJTSwfsXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ5QzhCQjQ5MDgzNDUwNjkyOUM5Mjg2NDE3 OEM4MzY5ODQ3RTE2NDg3AAoJEHjINphH4WSHsxUP/1HTSqIZu21b5WUVI6CH1kPG W/xzDJDNXL8Ga9UnUYOFfPEBvU8L9f2FWyJJPuCwieUY4TpWSOeOgtgAFvekfW12 hq740oVExiPEDTE1hknAKF3jtzHxVylORUK1jqTbx/pD5IzXJyaRALEX3unNYqD+ 87IAzpVVoIfRaBFnj8ErGTa9kk8VTUPu+enhjKzXOQMvtNltYXAGAESodXg11K+r Fihz40TQWg+qWGWvVhEmlbw7dFXlqd94C6BxDYAw6Od2BU4mpBf6If55GkV5dN7I UxklWBQ9TGxJs5ObYwaqGN9TntHWXlO6YJJHSTs8unv0JaOikRZvb4uICqHRCgBa mv6m4Q/B34LMoQqbw0dUxRvKdxwTDXMh8/ptNe0scK2IAHfRoX1Gbfr2NmkbTyrk lz472+f8gaQ5Dj6koLUQF/NQ9vvxQk9NACDpWSW9jVJwR2jdKT20RYRVCIWpivcP dTtZAjGU/Udo7zzZ/O8agB5pLL7GKQJqyslXDSJg0Un61Zza7KFyy4I49KDiRJGQ klPIkSb+T43Ign76kXe3izz+ZSUoZrIr0N/dGiUQztLunyR3/aOX0hDNjFdLpN7n gowgyEPSkKB2RILyu9H+P0zCyhwRzjXDffgiNuYHhx87ZBd73r6LkC82iuUwk8Hj 3eepULDuo9N+10IF6+2X =Iwb2 -----END PGP SIGNATURE----- --1GN7UObGkwVAwht6FBC0rn66egmRIsVe4--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?534B07EA.7080400>