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)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 19 Jul 2016 10:12:29 +0000 (20:12 +1000)
commit8fbaa51d43ef2c6a72849ec34060910723a0365f
tree8a6fa9290c3075f25b84154f6300cbffe3e94ed9
parent1e44727a0b220f6ead12fefcff997354be0f0f02
cxl: fix potential NULL dereference in free_adapter()

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>
drivers/misc/cxl/guest.c