All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch "cxl: fix potential NULL dereference in free_adapter()" has been added to the 4.7-stable tree
@ 2016-10-05 13:20 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2016-10-05 13:20 UTC (permalink / raw)
  To: andrew.donnellan, dan.carpenter, gregkh, mpe; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    cxl: fix potential NULL dereference in free_adapter()

to the 4.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     cxl-fix-potential-null-dereference-in-free_adapter.patch
and it can be found in the queue-4.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 8fbaa51d43ef2c6a72849ec34060910723a0365f Mon Sep 17 00:00:00 2001
From: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Date: Fri, 15 Jul 2016 17:20:36 +1000
Subject: cxl: fix potential NULL dereference in free_adapter()

From: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

commit 8fbaa51d43ef2c6a72849ec34060910723a0365f upstream.

If kzalloc() fails when allocating adapter->guest in
cxl_guest_init_adapter(), we call free_adapter() before erroring out.
free_adapter() in turn attempts to dereference adapter->guest, which in
this case is NULL.

In free_adapter(), skip the adapter->guest cleanup if adapter->guest is
NULL.

Fixes: 14baf4d9c739 ("cxl: Add guest-specific code")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/misc/cxl/guest.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

--- a/drivers/misc/cxl/guest.c
+++ b/drivers/misc/cxl/guest.c
@@ -1052,16 +1052,18 @@ static void free_adapter(struct cxl *ada
 	struct irq_avail *cur;
 	int i;
 
-	if (adapter->guest->irq_avail) {
-		for (i = 0; i < adapter->guest->irq_nranges; i++) {
-			cur = &adapter->guest->irq_avail[i];
-			kfree(cur->bitmap);
+	if (adapter->guest) {
+		if (adapter->guest->irq_avail) {
+			for (i = 0; i < adapter->guest->irq_nranges; i++) {
+				cur = &adapter->guest->irq_avail[i];
+				kfree(cur->bitmap);
+			}
+			kfree(adapter->guest->irq_avail);
 		}
-		kfree(adapter->guest->irq_avail);
+		kfree(adapter->guest->status);
+		kfree(adapter->guest);
 	}
-	kfree(adapter->guest->status);
 	cxl_remove_adapter_nr(adapter);
-	kfree(adapter->guest);
 	kfree(adapter);
 }
 


Patches currently in stable-queue which might be from andrew.donnellan@au1.ibm.com are

queue-4.7/cxl-fix-potential-null-dereference-in-free_adapter.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-05 13:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-05 13:20 Patch "cxl: fix potential NULL dereference in free_adapter()" has been added to the 4.7-stable tree gregkh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.