Skip to content

Commit

Permalink
thunderbolt: Fix a leak in tb_retimer_add()
Browse files Browse the repository at this point in the history
commit bec4d7c upstream.

After the device_register() succeeds, then the correct way to clean up
is to call device_unregister().  The unregister calls both device_del()
and device_put().  Since this code was only device_del() it results in
a memory leak.

Fixes: dacb128 ("thunderbolt: Add support for on-board retimers")
Cc: stable@vger.kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Apr 14, 2021
1 parent b830650 commit 256ece9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/thunderbolt/retimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static int tb_retimer_add(struct tb_port *port, u8 index, u32 auth_status)
ret = tb_retimer_nvm_add(rt);
if (ret) {
dev_err(&rt->dev, "failed to add NVM devices: %d\n", ret);
device_del(&rt->dev);
device_unregister(&rt->dev);
return ret;
}

Expand Down

0 comments on commit 256ece9

Please sign in to comment.