From nobody Tue Feb 10 10:08:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495684709759328.82691208878305; Wed, 24 May 2017 20:58:29 -0700 (PDT) Received: from localhost ([::1]:58016 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDjuu-0005JK-Gh for importer@patchew.org; Wed, 24 May 2017 23:58:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDjoP-0006Ur-Pm for qemu-devel@nongnu.org; Wed, 24 May 2017 23:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDjoO-0007TT-Fa for qemu-devel@nongnu.org; Wed, 24 May 2017 23:51:45 -0400 Received: from ozlabs.org ([103.22.144.67]:50725) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDjoO-0007SH-4K; Wed, 24 May 2017 23:51:44 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wYFgX55KLz9sCZ; Thu, 25 May 2017 13:51:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1495684296; bh=TNNvjKceCQza88EAo+/jIiBuROKP29zm+FkkU4vFrLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yd7oESkb4p6rbrjDSV+as0oWUO36dY6ydF/zdQD5Sd4ouLKBkPc+sPzxaJZRgsF35 Vy0oSZ2qLRbnkG+b/ceNwZZ0zA3k2JQW2HVbEWBFS/lWJCS5bldAtUo2dDujTqfEOC I1UGW0t8ZwFnUoCpR1VoYo8/+uc7Xk77YeJPfPGI= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 25 May 2017 13:51:21 +1000 Message-Id: <20170525035132.24268-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170525035132.24268-1-david@gibson.dropbear.id.au> References: <20170525035132.24268-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 07/18] spapr: ensure core_slot isn't NULL in spapr_core_unplug() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, aik@ozlabs.ru, sursingh@redhat.com, agraf@suse.de, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.org, sbobroff@redhat.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz If we go that far on the path of hot-removing a core and we find out that the core-id is invalid, then we have a serious bug. Let's make it explicit with an assert() instead of dereferencing a NULL pointer. This fixes Coverity issue CID 1375404. Signed-off-by: Greg Kurz Reviewed-by: Igor Mammedov Signed-off-by: David Gibson --- hw/ppc/spapr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 35dceb0..c912eaa 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2725,6 +2725,7 @@ static void spapr_core_unplug(HotplugHandler *hotplug= _dev, DeviceState *dev, CPUCore *cc =3D CPU_CORE(dev); CPUArchId *core_slot =3D spapr_find_cpu_slot(ms, cc->core_id, NULL); =20 + assert(core_slot); core_slot->cpu =3D NULL; object_unparent(OBJECT(dev)); } --=20 2.9.4