From nobody Tue May 7 16:06:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664538701; cv=none; d=zohomail.com; s=zohoarc; b=Z+QvzQimE8OVPsedTN2iihiWgyAVkAJhQQkJvhmOf6RWxWcuDIGo33/86lNBhs82EKMyjKXE0+UsclkXK5uZ4BsC5xCHyAQBVDxQpJwA41gDfbyHtsdDMxakU8Nagx75cdHJLggE2tGDQrpKYygPWnaSoZoNPG9PFuvDfssmTWw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664538701; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=TEzh44pXEkmHodSp4JvohR+OIzSnIfCRCzSCNapxNl8=; b=HBGj74+w4eaL4h2dvqaqVwAfIrN5NZL2wM8E/dm5D8V9KsXDNsEwpLAbi/rCK2QAtGGeSXyenp/cpmXTWWLb9kBYhqlwQvjjX8Jy44dbMnOrmPQzPElX/uWx11OS8oaZbSJrQgNivJk6cdvCnAkqWIjcJ05CqT0tfljBaPfDJjE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1664538701992299.18241799983025; Fri, 30 Sep 2022 04:51:41 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-h8Psgd_HODu_9tQABD2Tow-1; Fri, 30 Sep 2022 07:51:36 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56A1F1C068E6; Fri, 30 Sep 2022 11:51:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B1F4492B06; Fri, 30 Sep 2022 11:51:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 655D41946A54; Fri, 30 Sep 2022 11:51:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 09FED1946A52 for ; Fri, 30 Sep 2022 11:51:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A478D40C6EC4; Fri, 30 Sep 2022 11:51:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CB9D40C6EC2 for ; Fri, 30 Sep 2022 11:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664538700; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TEzh44pXEkmHodSp4JvohR+OIzSnIfCRCzSCNapxNl8=; b=VJJoTlfBfSATsIQMe1Fh7j7PwEZAnEqZcz87H3jIBuiYMIqQBOU6sJJhSbUf3WScY+d4Tv D3JHw3KUs1U2JHB/mC9m6XbZSY5DMn/8na+Lupxcmb943S8asFaIBMg8S+hqozKGa7jHtq QShPoLwir8ww/yg79Wxspc3tz1o+jVc= X-MC-Unique: h8Psgd_HODu_9tQABD2Tow-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH] virdomainjob: check if cb is not NULL before dereferencing Date: Fri, 30 Sep 2022 13:51:28 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664538703483100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The callback struct does not always have to be set which could cause a dereferencing of a NULL pointer. This patch adds check against NULL in missing places before dereferencing. Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko --- src/conf/virdomainjob.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/virdomainjob.c b/src/conf/virdomainjob.c index 0c67e84ef1..ca0215bc23 100644 --- a/src/conf/virdomainjob.c +++ b/src/conf/virdomainjob.c @@ -626,7 +626,7 @@ virDomainObjEndJob(virDomainObj *obj) =20 virDomainObjResetJob(obj->job); =20 - if (virDomainTrackJob(job) && + if (virDomainTrackJob(job) && obj->job->cb && obj->job->cb->saveStatusPrivate) obj->job->cb->saveStatusPrivate(obj); /* We indeed need to wake up ALL threads waiting because @@ -662,7 +662,7 @@ virDomainObjEndAsyncJob(virDomainObj *obj) obj, obj->def->name); =20 virDomainObjResetAsyncJob(obj->job); - if (obj->job->cb->saveStatusPrivate) + if (obj->job->cb && obj->job->cb->saveStatusPrivate) obj->job->cb->saveStatusPrivate(obj); virCondBroadcast(&obj->job->asyncCond); } --=20 2.37.3