Skip to content

Commit 05e8155

Browse files
Wan Jiabingdjbw
authored andcommitted
cxl/core/port: Fix NULL but dereferenced coccicheck error
Fix the following coccicheck warning: ./drivers/cxl/core/port.c:913:21-24: ERROR: port is NULL but dereferenced. The put_device() is only relevent in the is_cxl_root() case. Fixes: 2703c16 ("cxl/core/port: Add switch port enumeration") Signed-off-by: Wan Jiabing <wanjiabing@vivo.com> Link: https://lore.kernel.org/r/20220307094158.404882-1-wanjiabing@vivo.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 74be987 commit 05e8155

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/cxl/core/port.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,10 @@ static void cxl_detach_ep(void *data)
911911
break;
912912

913913
port = find_cxl_port(dport_dev);
914-
if (!port || is_cxl_root(port)) {
914+
if (!port)
915+
continue;
916+
917+
if (is_cxl_root(port)) {
915918
put_device(&port->dev);
916919
continue;
917920
}

0 commit comments

Comments
 (0)