Skip to content

Commit e6e17cc

Browse files
committed
cxl/core: Fix cxl_device_lock() class detection
If cxl_device_lock() is used on a non-CXL device the expectation is that the lock class will fall back to CXL_ANON_LOCK. Instead it crashes when trying to determine if the device is a 'decoder'. Specifically when the device has a NULL type pointer. Just check for NULL before de-referencing ->release. Fixes: 3c5b903 ("cxl: Prove CXL locking") Reported-by: Ben Widawsky <ben.widawsky@intel.com> Reviewed-by: Ben Widawsky <ben.widawsky@intel.com> Link: https://lore.kernel.org/r/164439225406.2941117.3927102269866914339.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 5c3c067 commit e6e17cc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/cxl/core/port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ EXPORT_SYMBOL_NS_GPL(is_root_decoder, CXL);
284284

285285
bool is_cxl_decoder(struct device *dev)
286286
{
287-
return dev->type->release == cxl_decoder_release;
287+
return dev->type && dev->type->release == cxl_decoder_release;
288288
}
289289
EXPORT_SYMBOL_NS_GPL(is_cxl_decoder, CXL);
290290

0 commit comments

Comments
 (0)