From nobody Sat May 4 15:05:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1492525565128751.6378708590238; Tue, 18 Apr 2017 07:26:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E3032C7709; Tue, 18 Apr 2017 14:26:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22092A2D8E; Tue, 18 Apr 2017 14:24:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E05431852FD3; Tue, 18 Apr 2017 14:15:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3I1vh1S007728 for ; Mon, 17 Apr 2017 21:57:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8338B17BA9; Tue, 18 Apr 2017 01:57:43 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BFF517BA1 for ; Tue, 18 Apr 2017 01:57:41 +0000 (UTC) Received: from mx7.zte.com.cn (mx7.zte.com.cn [202.103.147.169]) by mx1.redhat.com (Postfix) with ESMTP id 193C14DD7C for ; Tue, 18 Apr 2017 01:57:40 +0000 (UTC) Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 18 Apr 2017 01:52:45 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v3I1vF9N068340; Tue, 18 Apr 2017 09:57:15 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from localhost.localdomain ([10.74.121.225]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017041809571724-858376 ; Tue, 18 Apr 2017 09:57:17 +0800 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E3032C7709 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=zte.com.cn Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6E3032C7709 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 193C14DD7C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=zte.com.cn Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=wang.yi59@zte.com.cn DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 193C14DD7C X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170418095245 From: Yi Wang To: libvir-list@redhat.com Date: Tue, 18 Apr 2017 09:55:29 +0800 Message-Id: <1492480529-28762-1-git-send-email-wang.yi59@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-04-18 09:57:17, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-04-18 09:57:00, Serialize complete at 2017-04-18 09:57:00 X-MAIL: mse01.zte.com.cn v3I1vF9N068340 X-HQIP: 127.0.0.1 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 18 Apr 2017 01:57:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 18 Apr 2017 01:57:41 +0000 (UTC) for IP:'202.103.147.169' DOMAIN:'mx7.zte.com.cn' HELO:'mx7.zte.com.cn' FROM:'wang.yi59@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: -1.902 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 202.103.147.169 mx7.zte.com.cn 202.103.147.169 mx7.zte.com.cn X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Tue, 18 Apr 2017 10:15:44 -0400 Cc: Yi Wang , jdenemar@redhat.com, Liu.Jianjun3@zte.com.cn Subject: [libvirt] [PATCH] [PATCH] rpc: fix keep alive timer segfault X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 18 Apr 2017 14:26:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" ka maybe have been freeed in virObjectUnref, application using virKeepAliveTimer will segfault when unlock ka. We should keep ka's refs positive before using it. Signed-off-by: Yi Wang --- src/rpc/virkeepalive.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c index c9faf88..4f666fd 100644 --- a/src/rpc/virkeepalive.c +++ b/src/rpc/virkeepalive.c @@ -160,17 +160,17 @@ virKeepAliveTimer(int timer ATTRIBUTE_UNUSED, void *o= paque) bool dead; void *client; =20 + virObjectRef(ka); virObjectLock(ka); =20 client =3D ka->client; dead =3D virKeepAliveTimerInternal(ka, &msg); =20 + virObjectUnlock(ka); + if (!dead && !msg) goto cleanup; =20 - virObjectRef(ka); - virObjectUnlock(ka); - if (dead) { ka->deadCB(client); } else if (ka->sendCB(client, msg) < 0) { @@ -178,11 +178,8 @@ virKeepAliveTimer(int timer ATTRIBUTE_UNUSED, void *op= aque) virNetMessageFree(msg); } =20 - virObjectLock(ka); - virObjectUnref(ka); - cleanup: - virObjectUnlock(ka); + virObjectUnref(ka); } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list