From nobody Mon Feb 9 00:26:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1610037277; cv=none; d=zohomail.com; s=zohoarc; b=KFQlfyIBAI5IDgY2xfSvzv2Zo5sPjDylI2QLudQf34JR8b2SNOKUrytIEtIDjqrjsG8GTFXFC7mlV3+lzchhdyWWiFZfGSLz8UNxkx4gm1Fh2T6Ak8bmL5FloEncYlRdigjiunwY5AKNOSuR+VGjRaeQJSabGBuFYiBifBUftao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610037277; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q9fG1NpDIO93chK9X0WvSEBvAa8wcpFujX1n88f1bV8=; b=Q8OD7TBRuar+s8UrfOSiBg4SDMXZOQtCJtEgeHtJIxnP3t2fu6X2cu0P8L7zZ2CnINd5PPzHOIVTgjFHJR9lcihMFstoKZ42cDCgTcXCoVqwlQllM6FBezMvzPGXu+bSqRDD6gPx6RkMH9Q8pX05uLeLQROXDj7bHBaDT0nJGfo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1610037277929942.3625606242668; Thu, 7 Jan 2021 08:34:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-78-j1T9NHsbPLy4_t5rQst2rg-1; Thu, 07 Jan 2021 11:34:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07E4E18C89DC; Thu, 7 Jan 2021 16:34:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B44DE8416C; Thu, 7 Jan 2021 16:34:28 +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 72C994A7C6; Thu, 7 Jan 2021 16:34:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 107GYDPJ017306 for ; Thu, 7 Jan 2021 11:34:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8EDF010013BD; Thu, 7 Jan 2021 16:34:13 +0000 (UTC) Received: from nautilus.local (unknown [10.40.192.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id D537A1001E73; Thu, 7 Jan 2021 16:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610037276; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=q9fG1NpDIO93chK9X0WvSEBvAa8wcpFujX1n88f1bV8=; b=QNCoW9AgeQeZVmC3pc2glv0mCCQyvL9sCaCzGnA8a4MQjd8QMEfEezuW0eAOY0KI7dEoDj oy7ivcGlJoSH4ZDaAa+aYdp7FVO9byTlS1f2oniWjFrvRFslOebVmgs6q3o3mZwiBrG9HE 5rpMOFYs48TpjzvJBU7OXV/FVKZTeKk= X-MC-Unique: j1T9NHsbPLy4_t5rQst2rg-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] hostdev: Update mdev pointer reference after checking device type Date: Thu, 7 Jan 2021 17:34:06 +0100 Message-Id: <6b311456e9716194e1d9f7e1fea6ae243736dfe0.1610037231.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: eskultet@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We set the pointer to some garbage packed structure data without knowing whether it actually we were handling the type of device we expected to be handling. On its own, this was harmless, because we'd never use the pointer as we'd skip the device if it were not the expected type. However, it's better to make the logic even more explicit - we first check the device and only when we're sure we have the expected type we then update the pointer shortcut. Signed-off-by: Erik Skultety Reviewed-by: J=C3=A1n Tomko --- src/hypervisor/virhostdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 120187b07a..aa3fc8738f 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -1980,11 +1980,11 @@ virHostdevReAttachMediatedDevices(virHostdevManager= Ptr mgr, virDomainHostdevSubsysMediatedDevPtr mdevsrc; virDomainHostdevDefPtr hostdev =3D hostdevs[i]; =20 - mdevsrc =3D &hostdev->source.subsys.u.mdev; - if (!virHostdevIsMdevDevice(hostdev)) continue; =20 + mdevsrc =3D &hostdev->source.subsys.u.mdev; + if (!(mdev =3D virMediatedDeviceNew(mdevsrc->uuidstr, mdevsrc->model))) continue; --=20 2.29.2