Received: from eggs.gnu.org ([2001:4830:134:3::10]:42284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBdU-0006pH-RF for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:14:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoBdT-0007FD-Ue for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:14:20 -0400 From: Markus Armbruster References: <1459526222-30052-1-git-send-email-eblake@redhat.com> <56FEA749.7080509@redhat.com> Date: Thu, 07 Apr 2016 17:14:11 +0200 In-Reply-To: <56FEA749.7080509@redhat.com> (Max Reitz's message of "Fri, 1 Apr 2016 18:52:25 +0200") Message-ID: <8737qxxxh8.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [Qemu-block] [PATCH for-2.6] crypto: Avoid memory leak on failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, "open list:Block layer core" Max Reitz writes: > On 01.04.2016 17:57, Eric Blake wrote: >> Commit 7836857 introduced a memory leak due to invalid use of >> Error vs. visit_type_end(). If visiting the intermediate >> members fails, we clear the error and unconditionally use >> visit_end_struct() on the same error object; but if that >> cleanup succeeds, we then skip the qapi_free call. > > It's not really a memleak. Due to skipping those conditional branches > after the "out" label, a non-null value will be returned. In order to > determine whether the function call failed, the callers of these > functions do not use the errp value but the return value. Therefore, > they will think the call succeeded when actually it did not. Please amend the commit message accordingly. >> >> Until a later patch adds visit_check_struct(), the only safe >> approach is to use two separate error objects. >> >> Signed-off-by: Eric Blake >> --- >> block/crypto.c | 12 ++++++------ >> 1 file changed, 6 insertions(+), 6 deletions(-) > > Anyway, thanks, applied to my block branch: > > https://github.com/XanClic/qemu/commits/block > > Max