Skip to content

Commit

Permalink
media: dvb-frontends: fix memory leaks
Browse files Browse the repository at this point in the history
In dib7000pc_detection(), 'tx' and 'rx' are allocated through kzalloc()
respectively. However, if DiB7000PC is detected, they are not deallocated,
leading to memory leaks. To fix this issue, create a label to free 'tx' and
'rx' before returning from the function.

Signed-off-by: Wenwen Wang <[email protected]>
Signed-off-by: Sean Young <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
wenwenwang1 authored and mchehab committed Aug 21, 2019
1 parent 9fc3ce3 commit 8c3d3cd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/media/dvb-frontends/dib7000p.c
Original file line number Diff line number Diff line change
Expand Up @@ -2036,19 +2036,22 @@ static int dib7000pc_detection(struct i2c_adapter *i2c_adap)
if (i2c_transfer(i2c_adap, msg, 2) == 2)
if (rx[0] == 0x01 && rx[1] == 0xb3) {
dprintk("-D- DiB7000PC detected\n");
return 1;
ret = 1;
goto out;
}

msg[0].addr = msg[1].addr = 0x40;

if (i2c_transfer(i2c_adap, msg, 2) == 2)
if (rx[0] == 0x01 && rx[1] == 0xb3) {
dprintk("-D- DiB7000PC detected\n");
return 1;
ret = 1;
goto out;
}

dprintk("-D- DiB7000PC not detected\n");

out:
kfree(rx);
rx_memory_error:
kfree(tx);
Expand Down

0 comments on commit 8c3d3cd

Please sign in to comment.