diff mbox series

cxl/core/port: fix NULL but dereferenced coccicheck error

Message ID 20220307094158.404882-1-wanjiabing@vivo.com
State Accepted
Commit 05e815539f3f161585c13a9ab023341bade2c52f
Headers show
Series cxl/core/port: fix NULL but dereferenced coccicheck error | expand

Commit Message

Jiabing Wan March 7, 2022, 9:41 a.m. UTC
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@vivo.com>
---
 drivers/cxl/core/port.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Dan Williams March 22, 2022, 5:53 p.m. UTC | #1
On Mon, Mar 7, 2022 at 1:43 AM Wan Jiabing <wanjiabing@vivo.com> wrote:
>
> 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@vivo.com>

Thanks, applied.
diff mbox series

Patch

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;
 		}