Commit 3ca2f09
media: tegra-video: Fix memory leak in __tegra_channel_try_format()
[ Upstream commit 43e5302 ]
The state object allocated by __v4l2_subdev_state_alloc() must be freed
with __v4l2_subdev_state_free() when it is no longer needed.
In __tegra_channel_try_format(), two error paths return directly after
v4l2_subdev_call() fails, without freeing the allocated 'sd_state'
object. This violates the requirement and causes a memory leak.
Fix this by introducing a cleanup label and using goto statements in the
error paths to ensure that __v4l2_subdev_state_free() is always called
before the function returns.
Fixes: 56f64b8 ("media: tegra-video: Use zero crop settings if subdev has no get_selection")
Fixes: 1ebaeb0 ("media: tegra-video: Add support for external sensor capture")
Cc: stable@vger.kernel.org
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent a29639a commit 3ca2f09
1 file changed
+8
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | | - | |
| 443 | + | |
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
487 | | - | |
488 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
489 | 491 | | |
490 | 492 | | |
491 | 493 | | |
| |||
497 | 499 | | |
498 | 500 | | |
499 | 501 | | |
500 | | - | |
| 502 | + | |
501 | 503 | | |
502 | 504 | | |
503 | 505 | | |
504 | 506 | | |
| 507 | + | |
505 | 508 | | |
506 | 509 | | |
507 | | - | |
| 510 | + | |
508 | 511 | | |
509 | 512 | | |
510 | 513 | | |
| |||
0 commit comments