cxl/port: Fix NULL pointer access in devm_cxl_add_port()
PATCH 1/1 cxl/port: Fix NULL pointer access in devm_cxl_add_port()
In devm_cxl_add_port() the port creation may fail and its associated pointer does not contain a valid address. During error message generation this invalid port address is used. Fix that wrong address access.
--- drivers/cxl/core/port.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/cxl/core/port.c +3 -4
@@ -750,11 +750,10 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, parent_port = parent_dport ? parent_dport->port :NULL ;if (IS_ERR (port)) { -dev_dbg (uport,"Failed to add %s%s%s%s: %ld\n" , -dev_name (&port->dev), - parent_port ?" to " :"" , +dev_dbg (uport,"Failed to add%s%s%s: %ld\n" , + parent_port ?" port to " :"" , parent_port ?dev_name (&parent_port->dev) :"" , - parent_port ?"" :" (root port)" , + parent_port ?"" :" root port" ,PTR_ERR (port)); }else { dev_dbg(uport, "%s added%s%s%s\n",
base-commit: e764f12208b99ac7892c4e3f6bf88d71ca71036f
Signature · 1 line
2.30.2
Quoted 7 lines · Robert Richter
In
devm_cxl_add_port()the port creation may fail and its associated pointer does not contain a valid address. During error message generation this invalid port address is used. Fix that wrong address access.Fixes f3cd264c4ec1 ("cxl: Unify debug messages when calling devm_cxl_add_port()")Signed-off-by Robert Richter <[email protected]>
Quoted 25 lines
--- drivers/cxl/core/port.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/cxl/core/port.c +3
-4@@ -750,11 +750,10 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, parent_port = parent_dport ? parent_dport->port :NULL ;if (IS_ERR (port)) { -dev_dbg (uport,"Failed to add %s%s%s%s: %ld\n" , -dev_name (&port->dev), - parent_port ?" to " :"" , +dev_dbg (uport,"Failed to add%s%s%s: %ld\n" , + parent_port ?" port to " :"" , parent_port ?dev_name (&parent_port->dev) :"" , - parent_port ?"" :" (root port)" , + parent_port ?"" :" root port" ,PTR_ERR (port)); }else { dev_dbg(uport, "%s added%s%s%s\n",base-commit:
e764f12208b99ac7892c4e3f6bf88d71ca71036f
Quoted 18 lines · Robert Richter
In
devm_cxl_add_port()the port creation may fail and its associated pointer does not contain a valid address. During error message generation this invalid port address is used. Fix that wrong address access.Fixes f3cd264c4ec1 ("cxl: Unify debug messages when calling devm_cxl_add_port()")Signed-off-by Robert Richter <[email protected]>--- drivers/cxl/core/port.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/cxl/core/port.c +0
-0@@ -750,11 +750,10 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, parent_port = parent_dport ? parent_dport->port :NULL ;
drivers/cxl/core/port.c struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, · line 757
Quoted 10 lines
drivers/cxl/core/port.c +3
-4if (IS_ERR (port)) { -dev_dbg (uport,"Failed to add %s%s%s%s: %ld\n" , -dev_name (&port->dev), - parent_port ?" to " :"" , +dev_dbg (uport,"Failed to add%s%s%s: %ld\n" , + parent_port ?" port to " :"" , parent_port ?dev_name (&parent_port->dev) :"" , - parent_port ?"" :" (root port)" , + parent_port ?"" :" root port" ,PTR_ERR (port));
Looks good, applied.