Skip to content

Commit

Permalink
staging: fwserial: Fix error handling in fwserial_create
Browse files Browse the repository at this point in the history
[ Upstream commit f31559a ]

When fw_core_add_address_handler() fails, we need to destroy
the port by tty_port_destroy(). Also we need to unregister
the address handler by fw_core_remove_address_handler() on
failure.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Link: https://lore.kernel.org/r/20201221122437.10274-1-dinghao.liu@zju.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
dinghaoliu authored and gregkh committed Mar 7, 2021
1 parent a035837 commit b3854d1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/staging/fwserial/fwserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,7 @@ static int fwserial_create(struct fw_unit *unit)
err = fw_core_add_address_handler(&port->rx_handler,
&fw_high_memory_region);
if (err) {
tty_port_destroy(&port->port);
kfree(port);
goto free_ports;
}
Expand Down Expand Up @@ -2271,6 +2272,7 @@ static int fwserial_create(struct fw_unit *unit)

free_ports:
for (--i; i >= 0; --i) {
fw_core_remove_address_handler(&serial->ports[i]->rx_handler);
tty_port_destroy(&serial->ports[i]->port);
kfree(serial->ports[i]);
}
Expand Down

0 comments on commit b3854d1

Please sign in to comment.