[PATCH] cxl/core/port: fix NULL but dereferenced coccicheck error

From: Wan Jiabing
Date: Mon Mar 07 2022 - 05:11:14 EST


Fix the following coccicheck warning:
./drivers/cxl/core/port.c:913:21-24: ERROR: port is NULL but dereferenced.

Signed-off-by: Wan Jiabing <wanjiabing@xxxxxxxx>
---
drivers/cxl/core/port.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index d29eb2abdbc2..3349e9f7b89e 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -909,7 +909,10 @@ static void cxl_detach_ep(void *data)
break;

port = find_cxl_port(dport_dev);
- if (!port || is_cxl_root(port)) {
+ if (!port)
+ continue;
+
+ if (is_cxl_root(port)) {
put_device(&port->dev);
continue;
}
--
2.35.1