Commit dc9ceb90 authored by Zhipeng Lu's avatar Zhipeng Lu Committed by Mauro Carvalho Chehab
Browse files

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: 4114978d ("media: ir_toy: prevent device from hanging during transmit")
Signed-off-by: default avatarZhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 6a9d5524
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -332,6 +332,7 @@ 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;
	}

@@ -339,6 +340,7 @@ static int irtoy_tx(struct rc_dev *rc, uint *txbuf, uint count)
			    sizeof(COMMAND_SMODE_ENTER), STATE_COMMAND);
	if (err) {
		dev_err(irtoy->dev, "enter sample mode: %d\n", err);
		kfree(buf);
		return err;
	}