From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:55687 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752124AbcJENW0 (ORCPT ); Wed, 5 Oct 2016 09:22:26 -0400 Subject: Patch "cxl: fix potential NULL dereference in free_adapter()" has been added to the 4.7-stable tree To: andrew.donnellan@au1.ibm.com, dan.carpenter@oracle.com, gregkh@linuxfoundation.org, mpe@ellerman.id.au Cc: , From: Date: Wed, 05 Oct 2016 15:20:48 +0200 Message-ID: <147567364820118@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: 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 know about it. >>From 8fbaa51d43ef2c6a72849ec34060910723a0365f Mon Sep 17 00:00:00 2001 From: Andrew Donnellan Date: Fri, 15 Jul 2016 17:20:36 +1000 Subject: cxl: fix potential NULL dereference in free_adapter() From: Andrew Donnellan 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 Signed-off-by: Andrew Donnellan Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- 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