Skip to content

Commit b9b6838

Browse files
AlexiousLuHans Verkuil
authored andcommitted
media: go7007: fix a memleak in go7007_load_encoder
In go7007_load_encoder, bounce(i.e. go->boot_fw), is allocated without a deallocation thereafter. After the following call chain: saa7134_go7007_init |-> go7007_boot_encoder |-> go7007_load_encoder |-> kfree(go) go is freed and thus bounce is leaked. Fixes: 95ef394 ("[media] go7007: remember boot firmware") Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent 7a4cf27 commit b9b6838

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/media/usb/go7007/go7007-driver.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int go7007_load_encoder(struct go7007 *go)
8080
const struct firmware *fw_entry;
8181
char fw_name[] = "go7007/go7007fw.bin";
8282
void *bounce;
83-
int fw_len, rv = 0;
83+
int fw_len;
8484
u16 intr_val, intr_data;
8585

8686
if (go->boot_fw == NULL) {
@@ -109,9 +109,11 @@ static int go7007_load_encoder(struct go7007 *go)
109109
go7007_read_interrupt(go, &intr_val, &intr_data) < 0 ||
110110
(intr_val & ~0x1) != 0x5a5a) {
111111
v4l2_err(go, "error transferring firmware\n");
112-
rv = -1;
112+
kfree(go->boot_fw);
113+
go->boot_fw = NULL;
114+
return -1;
113115
}
114-
return rv;
116+
return 0;
115117
}
116118

117119
MODULE_FIRMWARE("go7007/go7007fw.bin");

0 commit comments

Comments
 (0)