2022-03-07 10:35:11

by Jiabing Wan

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Wan Jiabing <[email protected]>
---
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


2022-03-25 01:12:19

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCH] cxl/core/port: fix NULL but dereferenced coccicheck error

On Mon, Mar 7, 2022 at 1:43 AM Wan Jiabing <[email protected]> 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 <[email protected]>

Thanks, applied.