From patchwork Fri Jan 11 06:37:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10757473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7179A1399 for ; Fri, 11 Jan 2019 06:37:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 612FD29AEC for ; Fri, 11 Jan 2019 06:37:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 528A929AFF; Fri, 11 Jan 2019 06:37:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CEC729AEC for ; Fri, 11 Jan 2019 06:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731006AbfAKGh5 (ORCPT ); Fri, 11 Jan 2019 01:37:57 -0500 Received: from mail-pl1-f170.google.com ([209.85.214.170]:39838 "EHLO mail-pl1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbfAKGh5 (ORCPT ); Fri, 11 Jan 2019 01:37:57 -0500 Received: by mail-pl1-f170.google.com with SMTP id 101so6326130pld.6 for ; Thu, 10 Jan 2019 22:37:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EaEm7GhKPLbm8j7I19095wyJJWd37TUtwImyNV9Ffpw=; b=tkh3duRO6nuUWaTs25iLN/Fb1O3BUz89l/vxM97eUGMtyS5k2qfgxVO+Xi0E/jkF0K cOSbw2cfy6fLF7i5AG4HoYRqtf2RYMKKxRiQrKm0REvGNZnZQ3qytdL/l8Q3ml3ar3oC 9J8IKxM6VkziJaL3tkxCP7ujn2LdXmTBFWCLUaAvXg8U36lqMZ+jvbtcuG82ghJBra9z kyw4LFRJOKhl9wtLS4yrh6Mfzn6MbBevqsOA0F3z2RlW+a6EqQEANI9c+yNQLeyz1W/k yuRmoWLPgpnOw7m04VXc5+gv8kk1pWYsqDlsrfOHnewbwvrw5NevTjW+4Mx/NvsT/U5x MUcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EaEm7GhKPLbm8j7I19095wyJJWd37TUtwImyNV9Ffpw=; b=IUPcLd5tLQaWgfZbmhfnCYRT1Bwkb/j9PRxtD0k5Zn9PmlksWhxR3jntaJVWdkA7DY WQQsqTSgyedm3VuR46emEP+dTEXj05wTImmgllO5IedJIPrtT8DE4kkTuqEv0AHVB0XM gP/C6m3G8/2elRcJezwqY7OTTc9SAyK5pgI/MxsTIbPWII/0On1xBEudSnUjwst1jMjA e3UbOPUuMwMyXHNKIGFiYjDJiUghVsvHpfPnd284VgdxzRa08DmhvS5f5uHUy5dkaJU7 90wAdZIZQ6uJXmCwR/TIKZE6BFkwon/vfvtQH2H5OP0s+yNnCkdaQw/qfDDO88wFi8WA MQBA== X-Gm-Message-State: AJcUukcZyQSKZVtosZd4scwxRK6/1wiiuf8OiQzX9jORzM8sy6LgGch4 Y6mUygpwbli2GgaptswOhwEOYjyu X-Google-Smtp-Source: ALg8bN63YWcQNfj+sMHNFX2B3oEp62u/Y/ZVIgH5NNUFqH0ne4ue/kHwigepgVVSasTo7YW2+IyB7A== X-Received: by 2002:a17:902:34a:: with SMTP id 68mr13751093pld.268.1547188676338; Thu, 10 Jan 2019 22:37:56 -0800 (PST) Received: from localhost.localdomain ([203.205.141.36]) by smtp.gmail.com with ESMTPSA id 78sm141460933pft.184.2019.01.10.22.37.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Jan 2019 22:37:55 -0800 (PST) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com, peterx@redhat.com, wei.w.wang@intel.com, eblake@redhat.com, quintela@redhat.com, cota@braap.org, Xiao Guangrong Subject: [PATCH v2 2/3] migration: fix memory leak when updating tls-creds and tls-hostname Date: Fri, 11 Jan 2019 14:37:31 +0800 Message-Id: <20190111063732.10484-3-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20190111063732.10484-1-xiaoguangrong@tencent.com> References: <20190111063732.10484-1-xiaoguangrong@tencent.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xiao Guangrong If we update parameter, tls-creds and tls-hostname, these string values are duplicated to local variables in migrate_params_test_apply() by using g_strdup(), however these new allocated memory are missed to be freed Actually, they are not used to check anything, we can directly skip them Signed-off-by: Xiao Guangrong --- migration/migration.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index a82d594f29..fb39d7bec1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1145,16 +1145,6 @@ static void migrate_params_test_apply(MigrateSetParameters *params, dest->cpu_throttle_increment = params->cpu_throttle_increment; } - if (params->has_tls_creds) { - assert(params->tls_creds->type == QTYPE_QSTRING); - dest->tls_creds = g_strdup(params->tls_creds->u.s); - } - - if (params->has_tls_hostname) { - assert(params->tls_hostname->type == QTYPE_QSTRING); - dest->tls_hostname = g_strdup(params->tls_hostname->u.s); - } - if (params->has_max_bandwidth) { dest->max_bandwidth = params->max_bandwidth; }