[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <5a34a77e-d1bf-c630-ef9b-4f94c2c0c221@canonical.com>
Date: Wed, 1 May 2019 15:42:53 +0100
From: Colin Ian King <colin.king@...onical.com>
To: Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>,
kvm@...r.kernel.org,
Cédric Le Goater <clg@...d.org>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: re: KVM: Introduce a 'release' method for KVM devices
Hi,
Static analysis with Coverity picked up an issue in the following commit:
commit 2bde9b3ec8bdf60788e9e2ce8c07a2f8d6003dbd
Author: Cédric Le Goater <clg@...d.org>
Date: Thu Apr 18 12:39:41 2019 +0200
KVM: Introduce a 'release' method for KVM devices
struct kvm *kvm = dev->kvm;
+ if (!dev)
+ return -ENODEV;
If dev is null then the dereference of dev->kvm when assigning pointer
kvm will cause an null pointer dereference. This is easily fixed by
assigning kvm after the dev null check.
+
+ if (dev->kvm != kvm)
+ return -EPERM;
I don't understand the logic of the above check. kvm is the same
dev->kvm on the earlier assignment, so dev->kvm != kvm seems to be
always false, so this check seems to be redundant. Am I missing
something more fundamental here?
Colin
Powered by blists - more mailing lists