@@ -2372,19 +2372,16 @@ EXPORT_SYMBOL_GPL(typec_port_register_cable_ops);
struct typec_port *typec_register_port(struct device *parent,
const struct typec_capability *cap)
{
- struct typec_port *port;
int ret;
int id;
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ struct typec_port *port __free(kfree) = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port)
return ERR_PTR(-ENOMEM);
id = ida_alloc(&typec_index_ida, GFP_KERNEL);
- if (id < 0) {
- kfree(port);
+ if (id < 0)
return ERR_PTR(id);
- }
switch (cap->type) {
case TYPEC_PORT_SRC:
@@ -2483,7 +2480,7 @@ struct typec_port *typec_register_port(struct device *parent,
if (ret)
dev_warn(&port->dev, "failed to create symlinks (%d)\n", ret);
- return port;
+ return_ptr(port);
}
EXPORT_SYMBOL_GPL(typec_register_port);