Skip to content

Commit

Permalink
HSI: core: Fix return freed object in hsi_new_client
Browse files Browse the repository at this point in the history
[ Upstream commit a1ee1c0 ]

cl is freed on error of calling device_register, but this
object is return later, which will cause uaf issue. Fix it
by return NULL on error.

Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Ychame authored and gregkh committed Jan 27, 2022
1 parent 8c12460 commit 0c3df09
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/hsi/hsi_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct hsi_client *hsi_new_client(struct hsi_port *port,
if (device_register(&cl->device) < 0) {
pr_err("hsi: failed to register client: %s\n", info->name);
put_device(&cl->device);
goto err;
}

return cl;
Expand Down

0 comments on commit 0c3df09

Please sign in to comment.