]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cxl: fix potential NULL dereference in free_adapter()
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Fri, 15 Jul 2016 07:20:36 +0000 (17:20 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Oct 2016 13:21:24 +0000 (15:21 +0200)
commitb3c5b399e6614c17c428e453e528b7c717edbf2c
treeacc0930b0658618c0c6c3e4535b2c890f8079b0e
parentb7d9885f97676b5b0c5162bd4720c1f956306813
cxl: fix potential NULL dereference in free_adapter()

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