From nobody Sat Nov 15 14:14:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1595388844; cv=none; d=zohomail.com; s=zohoarc; b=mMB1s7s3mYSmCSZ3r5Oh89tXY/3RdpVwgg64xLvuW53Bv5wlyTZqrTvlT5qLFdUx52VRfviVwZCnpo+8zVqsfIDH2hGogl/qssN8Heomxk5fLYgjc4SapbGePevYy/gEvsknJozLnqB5lAnibs7sR7sN8o289pxVOVHBKgwnuGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595388844; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=b3jzgAEF6Kx+zjYAGO6+2bGop1OG+SjJBt5XOkd7W3U=; b=mNBiYom7ZeZzlyXLrEVZ3bKLXMgYVtcDaDgLg0bcowb/DN+q87TVgBAokxIA8zCj7DT2DAosWe74HCENHy/kiAOxE0zkyx5cabj1lMZmkHfpapr9Vzy1jaescCS+cMSgBAkIhEHxfSK01dj1PcoAVOAJZZpShygUsAtdZthJ+sg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1595388844273621.0361698317715; Tue, 21 Jul 2020 20:34:04 -0700 (PDT) Received: from localhost ([::1]:41384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jy5W7-0000c0-3V for importer@patchew.org; Tue, 21 Jul 2020 23:34:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jy5V2-0008CY-P5 for qemu-devel@nongnu.org; Tue, 21 Jul 2020 23:32:56 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:39210 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jy5V0-0001nB-NU for qemu-devel@nongnu.org; Tue, 21 Jul 2020 23:32:56 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 12D0974C484305D92D5B; Wed, 22 Jul 2020 11:32:46 +0800 (CST) Received: from DESKTOP-KKJBAGG.china.huawei.com (10.174.186.173) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Wed, 22 Jul 2020 11:32:40 +0800 From: Zhenyu Ye To: Subject: [PATCH v1] migration: tls: fix memory leak in migration_tls_get_creds Date: Wed, 22 Jul 2020 11:32:28 +0800 Message-ID: <20200722033228.71-1-yezhenyu2@huawei.com> X-Mailer: git-send-email 2.22.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.186.173] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.32; envelope-from=yezhenyu2@huawei.com; helo=huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/21 23:32:46 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com, quintela@redhat.com, yezhenyu2@huawei.com, dgilbert@redhat.com, xiexiangyou@huawei.com, zhengchuan@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Currently migration_tls_get_creds() adds the reference of creds but there was no place to unref it. So the OBJECT(creds) will never be freed and result in memory leak. The leak stack: Direct leak of 104 byte(s) in 1 object(s) allocated from: #0 0xffffa88bd20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd3= 20b) #1 0xffffa7f0cb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b) #2 0x14b58cb in object_new_with_type qom/object.c:634 #3 0x14b597b in object_new qom/object.c:645 #4 0x14c0e4f in user_creatable_add_type qom/object_interfaces.c:59 #5 0x141c78b in qmp_object_add qom/qom-qmp-cmds.c:312 #6 0x140e513 in qmp_marshal_object_add qapi/qapi-commands-qom.c:279 #7 0x176ba97 in do_qmp_dispatch qapi/qmp-dispatch.c:165 #8 0x176bee7 in qmp_dispatch qapi/qmp-dispatch.c:208 #9 0x136e337 in monitor_qmp_dispatch monitor/qmp.c:150 #10 0x136eae3 in monitor_qmp_bh_dispatcher monitor/qmp.c:239 #11 0x1852e93 in aio_bh_call util/async.c:89 #12 0x18531b7 in aio_bh_poll util/async.c:117 #13 0x18616bf in aio_dispatch util/aio-posix.c:459 #14 0x1853f37 in aio_ctx_dispatch util/async.c:268 #15 0xffffa7f06a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.s= o.0+0x52a7b) Since we're fine to use the borrowed reference when using the creds, so just remove the object_ref() in migration_tls_get_creds(). Signed-off-by: Zhenyu Ye Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/tls.c | 1 - 1 file changed, 1 deletion(-) diff --git a/migration/tls.c b/migration/tls.c index 5171afc6c4..7a02ec8656 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -58,7 +58,6 @@ migration_tls_get_creds(MigrationState *s, return NULL; } =20 - object_ref(OBJECT(ret)); return ret; } =20 --=20 2.19.1