Skip to content

Commit

Permalink
media: tw686x: Fix memory leak in tw686x_video_init
Browse files Browse the repository at this point in the history
video_device_alloc() allocates memory for vdev,
when video_register_device() fails, it doesn't release the memory and
leads to memory leak, call video_device_release() to fix this.

Fixes: 704a84c ("[media] media: Support Intersil/Techwell TW686x-based video capture cards")
Signed-off-by: Miaoqian Lin <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Yuuoniy authored and mchehab committed Jun 27, 2022
1 parent 5b30404 commit e0b212e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/media/pci/tw686x/tw686x-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,8 +1280,10 @@ int tw686x_video_init(struct tw686x_dev *dev)
video_set_drvdata(vdev, vc);

err = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
if (err < 0)
if (err < 0) {
video_device_release(vdev);
goto error;
}
vc->num = vdev->num;
}

Expand Down

0 comments on commit e0b212e

Please sign in to comment.