Skip to content

Commit dc9ceb9

Browse files
AlexiousLumchehab
authored andcommitted
media: ir_toy: fix a memleak in irtoy_tx
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>
1 parent 6a9d552 commit dc9ceb9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/media/rc/ir_toy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,15 @@ static int irtoy_tx(struct rc_dev *rc, uint *txbuf, uint count)
332332
sizeof(COMMAND_SMODE_EXIT), STATE_COMMAND_NO_RESP);
333333
if (err) {
334334
dev_err(irtoy->dev, "exit sample mode: %d\n", err);
335+
kfree(buf);
335336
return err;
336337
}
337338

338339
err = irtoy_command(irtoy, COMMAND_SMODE_ENTER,
339340
sizeof(COMMAND_SMODE_ENTER), STATE_COMMAND);
340341
if (err) {
341342
dev_err(irtoy->dev, "enter sample mode: %d\n", err);
343+
kfree(buf);
342344
return err;
343345
}
344346

0 commit comments

Comments
 (0)