]> Git Repo - J-linux.git/commitdiff
cxl/core/port: Fix NULL but dereferenced coccicheck error
authorWan Jiabing <[email protected]>
Mon, 7 Mar 2022 09:41:48 +0000 (17:41 +0800)
committerDan Williams <[email protected]>
Tue, 22 Mar 2022 17:51:17 +0000 (10:51 -0700)
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: 2703c16c75ae ("cxl/core/port: Add switch port enumeration")
Signed-off-by: Wan Jiabing <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Dan Williams <[email protected]>
drivers/cxl/core/port.c

index c1681248f3221b138a4d67d18c0c987bedc2ba66..2ab1ba4499b309f7e7097e4044cfb90eb415c380 100644 (file)
@@ -911,7 +911,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;
                }
This page took 0.047322 seconds and 4 git commands to generate.