Received: from eggs.gnu.org ([2001:4830:134:3::10]:58964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFmzS-0001O7-TE for qemu-devel@nongnu.org; Tue, 18 Feb 2014 10:53:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFmzO-00088y-39 for qemu-devel@nongnu.org; Tue, 18 Feb 2014 10:53:46 -0500 Received: from afflict.kos.to ([92.243.29.197]:33389) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFmzN-00088p-R4 for qemu-devel@nongnu.org; Tue, 18 Feb 2014 10:53:41 -0500 Date: Tue, 18 Feb 2014 17:53:40 +0200 From: Riku Voipio Message-ID: <20140218155340.GA32053@afflict.kos.to> References: <1392663334-8555-1-git-send-email-peter.maydell@linaro.org> <1392663334-8555-5-git-send-email-peter.maydell@linaro.org> <20140218151007.GA30891@afflict.kos.to> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 4/4] linux-user: Fix error handling in target_to_host_semarray() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Riku Voipio , QEMU Developers On Tue, Feb 18, 2014 at 03:11:37PM +0000, Peter Maydell wrote: > On 18 February 2014 15:10, Riku Voipio wrote: > > On Mon, Feb 17, 2014 at 06:55:34PM +0000, Peter Maydell wrote: > >> Fix two issues in error handling in target_to_host_semarray(): > >> * don't leak the host_array buffer if lock_user fails > >> * return an error if malloc() fails > > > > With this patch I get on ubuntu raring x86_64 (gcc 4.7): > > > > In function =E2=80=98target_to_host_semarray=E2=80=99, > > inlined from =E2=80=98do_semctl=E2=80=99 at /home/voipio/linaro/q= emu/linux-user/syscall.c:2502:17, > > inlined from =E2=80=98do_syscall=E2=80=99 at /home/voipio/linaro/= qemu/linux-user/syscall.c:6917:13: > > /home/voipio/linaro/qemu/linux-user/syscall.c:2439:13: error: attempt= to free a non-heap object =E2=80=98array=E2=80=99 [-Werror=3Dfree-nonhea= p-object] > > cc1: all warnings being treated as errors >=20 > Doh. Missing '*': >=20 > >> > >> *host_array =3D malloc(nsems*sizeof(unsigned short)); > >> + if (!*host_array) { > >> + return -TARGET_ENOMEM; > >> + } > >> array =3D lock_user(VERIFY_READ, target_addr, > >> nsems*sizeof(unsigned short), 1); > >> - if (!array) > >> + if (!array) { > >> + free(host_array); >=20 > ...should be > free(*host_array); Edited and updated patch in my linux-user updates branch. Riku