Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] s5p-mfc: Fix clock management in s5p_mfc_release() function

Clock control indirectly requires access to MFC device, so call it only
if we are sure that the device exists in s5p_mfc_release function.
s5p_mfc_remove() calls s5p_mfc_final_pm(), which releases all PM related
resources, including clocks, so any call to clocks related functions
is not valid after s5p_mfc_final_pm().

Fixes: d695c12 ("[media] media: s5p-mfc fix invalid memory access from
s5p_mfc_release()")

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Marek Szyprowski and committed by
Mauro Carvalho Chehab
c0026c7b c5086f13

+4 -3
+4 -3
drivers/media/platform/s5p-mfc/s5p_mfc.c
··· 929 929 mfc_debug_enter(); 930 930 if (dev) 931 931 mutex_lock(&dev->mfc_mutex); 932 - s5p_mfc_clock_on(); 933 932 vb2_queue_release(&ctx->vq_src); 934 933 vb2_queue_release(&ctx->vq_dst); 935 934 if (dev) { 935 + s5p_mfc_clock_on(); 936 + 936 937 /* Mark context as idle */ 937 938 clear_work_bit_irqsave(ctx); 938 939 /* ··· 955 954 if (s5p_mfc_power_off() < 0) 956 955 mfc_err("Power off failed\n"); 957 956 } 957 + mfc_debug(2, "Shutting down clock\n"); 958 + s5p_mfc_clock_off(); 958 959 } 959 - mfc_debug(2, "Shutting down clock\n"); 960 - s5p_mfc_clock_off(); 961 960 if (dev) 962 961 dev->ctx[ctx->num] = NULL; 963 962 s5p_mfc_dec_ctrls_delete(ctx);