Skip to content

Commit

Permalink
media: ir_toy: fix a memleak in irtoy_tx
Browse files Browse the repository at this point in the history
[ Upstream commit dc9ceb9 ]

When irtoy_command fails, buf should be freed since it is allocated by
irtoy_tx, or there is a memleak.

Fixes: 4114978 ("media: ir_toy: prevent device from hanging during transmit")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
AlexiousLu authored and gregkh committed Feb 23, 2024
1 parent 008cf5d commit 7219a69
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/media/rc/ir_toy.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,15 @@ static int irtoy_tx(struct rc_dev *rc, uint *txbuf, uint count)
sizeof(COMMAND_SMODE_EXIT), STATE_COMMAND_NO_RESP);
if (err) {
dev_err(irtoy->dev, "exit sample mode: %d\n", err);
kfree(buf);
return err;
}

err = irtoy_command(irtoy, COMMAND_SMODE_ENTER,
sizeof(COMMAND_SMODE_ENTER), STATE_COMMAND);
if (err) {
dev_err(irtoy->dev, "enter sample mode: %d\n", err);
kfree(buf);
return err;
}

Expand Down

0 comments on commit 7219a69

Please sign in to comment.