From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AF59C433EF for ; Mon, 6 Dec 2021 11:40:40 +0000 (UTC) Received: from localhost ([::1]:34598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muCMI-0002Rk-OF for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 06:40:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muCLX-0001k7-Lr for qemu-devel@nongnu.org; Mon, 06 Dec 2021 06:39:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56317) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muCLS-0004GN-9y for qemu-devel@nongnu.org; Mon, 06 Dec 2021 06:39:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638790784; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=J0vYyCuHdyRzpBi1sMVSH9sfGOEAhuHj7K4jWXvi/Fw=; b=F416CUypWdpljHeFCNj3uypWAB9hqc9cCaAtPcBnuvEiypWot03NoCrh+jKshFRlImEssz K3JM2GC2McmUaN0fewh2ggZ+qSgg0xN1ISld/T6t4EwZFUo/kle8rF9MDGtrBwR3U32duB T4EV0VcmNI8pNuSDXb77/3WbJsSFYqo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-180-tmnrcNboNBCBU0W853ujLA-1; Mon, 06 Dec 2021 06:39:38 -0500 X-MC-Unique: tmnrcNboNBCBU0W853ujLA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E753F94EE1; Mon, 6 Dec 2021 11:39:37 +0000 (UTC) Received: from redhat.com (unknown [10.33.36.73]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7BF479454; Mon, 6 Dec 2021 11:39:36 +0000 (UTC) Date: Mon, 6 Dec 2021 11:39:34 +0000 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= To: Li Zhang Subject: Re: [PATCH 1/1] kvm: Clear variables which may not be used Message-ID: References: <20211206112738.14893-1-lizhang@suse.de> MIME-Version: 1.0 In-Reply-To: <20211206112738.14893-1-lizhang@suse.de> User-Agent: Mutt/2.1.3 (2021-09-10) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.619, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= Cc: pbonzini@redhat.com, cfontana@suse.de, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Mon, Dec 06, 2021 at 12:27:38PM +0100, Li Zhang wrote: > The variables msi, route in kvm_irqchip_send_msi may be uninitialised > values in some cases. It's necessary to clear them. You say the patch is going to 'clear them' but.... > > Signed-off-by: Li Zhang > --- > accel/kvm/kvm-all.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c > index eecd8031cf..bd50dc6b80 100644 > --- a/accel/kvm/kvm-all.c > +++ b/accel/kvm/kvm-all.c > @@ -1913,10 +1913,8 @@ static KVMMSIRoute *kvm_lookup_msi_route(KVMState *s, MSIMessage msg) > > int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) > { > - struct kvm_msi msi; > - KVMMSIRoute *route; > - > if (kvm_direct_msi_allowed) { > + struct kvm_msi msi; ...but this is still an uninitialized declaration. > msi.address_lo = (uint32_t)msg.address; > msi.address_hi = msg.address >> 32; > msi.data = le32_to_cpu(msg.data); I guess the bug you were wanting to fix is that this code only initializes 5 out of 6 struct fields, before calling the ioctl. > @@ -1926,6 +1924,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) > return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi); > } > > + KVMMSIRoute *route; This was initialized correctly before and didn't need moving > route = kvm_lookup_msi_route(s, msg); > if (!route) { > int virq; Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|