Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1AAFC2BBC7 for ; Thu, 9 Apr 2020 14:13:10 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D3E0208FE for ; Thu, 9 Apr 2020 14:13:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D3E0208FE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jMXvF-0002nv-2C; Thu, 09 Apr 2020 14:12:49 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jMXvD-0002nk-T3 for xen-devel@lists.xenproject.org; Thu, 09 Apr 2020 14:12:47 +0000 X-Inumbo-ID: 2f0d72f6-7a6c-11ea-82d6-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2f0d72f6-7a6c-11ea-82d6-12813bfff9fa; Thu, 09 Apr 2020 14:12:46 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0607EAE59; Thu, 9 Apr 2020 14:12:43 +0000 (UTC) From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Subject: [PATCH 2/3] mini-os: fix double free() in xenbus Date: Thu, 9 Apr 2020 16:12:39 +0200 Message-Id: <20200409141240.28876-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200409141240.28876-1-jgross@suse.com> References: <20200409141240.28876-1-jgross@suse.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , samuel.thibault@ens-lyon.org, wl@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Commit 973ad0c4de1b48 ("Save/Restore Support: Add suspend/restore support for xenbus") introduced a double free of some memory and leaked another memory allocation. Fix those. Coverity-ID: 1433640 Fixes: 973ad0c4de1b48 ("Save/Restore Support: Add suspend/restore support for xenbus") Signed-off-by: Juergen Gross --- xenbus/xenbus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c index d72dc3a..b12cef7 100644 --- a/xenbus/xenbus.c +++ b/xenbus/xenbus.c @@ -413,9 +413,11 @@ void resume_xenbus(int canceled) rep = xenbus_msg_reply(XS_WATCH, XBT_NIL, req, ARRAY_SIZE(req)); msg = errmsg(rep); - if (msg) + if (msg) { xprintk("error on XS_WATCH: %s\n", msg); - free(rep); + free(msg); + } else + free(rep); } } -- 2.16.4