Linux CXL
 help / color / mirror / Atom feed
* [PATCH] cxl/core: Fix cxl_device_lock() class detection
@ 2022-02-09  7:37 Dan Williams
  2022-02-09 17:39 ` Ben Widawsky
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Williams @ 2022-02-09  7:37 UTC (permalink / raw)
  To: linux-cxl; +Cc: Ben Widawsky

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: 3c5b90395525 ("cxl: Prove CXL locking")
Reported-by: Ben Widawsky <ben.widawsky@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/cxl/core/port.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 9b4bbd51fbaa..d29eb2abdbc2 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -284,7 +284,7 @@ EXPORT_SYMBOL_NS_GPL(is_root_decoder, CXL);
 
 bool is_cxl_decoder(struct device *dev)
 {
-	return dev->type->release == cxl_decoder_release;
+	return dev->type && dev->type->release == cxl_decoder_release;
 }
 EXPORT_SYMBOL_NS_GPL(is_cxl_decoder, CXL);
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cxl/core: Fix cxl_device_lock() class detection
  2022-02-09  7:37 [PATCH] cxl/core: Fix cxl_device_lock() class detection Dan Williams
@ 2022-02-09 17:39 ` Ben Widawsky
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Widawsky @ 2022-02-09 17:39 UTC (permalink / raw)
  To: Dan Williams; +Cc: linux-cxl

On 22-02-08 23:37:34, Dan Williams wrote:
> 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: 3c5b90395525 ("cxl: Prove CXL locking")
> Reported-by: Ben Widawsky <ben.widawsky@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Ben Widawsky <ben.widawsky@intel.com>

> ---
>  drivers/cxl/core/port.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 9b4bbd51fbaa..d29eb2abdbc2 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -284,7 +284,7 @@ EXPORT_SYMBOL_NS_GPL(is_root_decoder, CXL);
>  
>  bool is_cxl_decoder(struct device *dev)
>  {
> -	return dev->type->release == cxl_decoder_release;
> +	return dev->type && dev->type->release == cxl_decoder_release;
>  }
>  EXPORT_SYMBOL_NS_GPL(is_cxl_decoder, CXL);
>  
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-09 17:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-09  7:37 [PATCH] cxl/core: Fix cxl_device_lock() class detection Dan Williams
2022-02-09 17:39 ` Ben Widawsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox