Skip to contentSkip to conversation

ccdc_update_raw_params() frees the wrong thing

PATCH In review Al Viro 2 participants 4 messages Dec 13, 2015 – Jan 6, 2016 Media (V4L/DVB)

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 ccdc_update_raw_params() frees the wrong thing

Passing a physical address to free_pages() is a bad idea.
config_params->fault_pxl.fpc_table_addr is set to virt_to_phys() of __get_free_pages() return value; what we should pass to free_pages() is its phys_to_virt(). ccdc_close() does that properly, but ccdc_update_raw_params() doesn't.

drivers/media/platform/davinci/dm644x_ccdc.c +1 -1
index ffbefdf..6fba32b 100644
@@ -261,7 +261,7 @@ static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params)
 	 */
 	if (raw_params->fault_pxl.fp_num != config_params->fault_pxl.fp_num) {
 		if (fpc_physaddr != NULL) {
-			free_pages((unsigned long)fpc_physaddr,
+			free_pages((unsigned long)fpc_virtaddr,
 				   get_order
 				   (config_params->fault_pxl.fp_num *
 				   FP_NUM_BYTES));
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Al Viro

Passing a physical address to free_pages() is a bad idea.
config_params->fault_pxl.fpc_table_addr is set to virt_to_phys() of __get_free_pages() return value; what we should pass to free_pages() is its phys_to_virt(). ccdc_close() does that properly, but ccdc_update_raw_params() doesn't.

Regards,
--Prabhakar Lad

Quoted 13 lines
drivers/media/platform/davinci/dm644x_ccdc.c +1 -1
index ffbefdf..6fba32b 100644
@@ -261,7 +261,7 @@ static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params)
         */
        if (raw_params->fault_pxl.fp_num != config_params->fault_pxl.fp_num) {
                if (fpc_physaddr != NULL) {
-                       free_pages((unsigned long)fpc_physaddr,
+                       free_pages((unsigned long)fpc_virtaddr,
                                   get_order
                                   (config_params->fault_pxl.fp_num *
                                   FP_NUM_BYTES));
author
#2 lore raw
Quoted 7 lines · Prabhakar
Quoted 6 lines · Al Viro

Passing a physical address to free_pages() is a bad idea.
config_params->fault_pxl.fpc_table_addr is set to virt_to_phys() of __get_free_pages() return value; what we should pass to free_pages() is its phys_to_virt(). ccdc_close() does that properly, but ccdc_update_raw_params() doesn't.

Quoted 6 lines
Quoted 2 lines

Regards,
--Prabhakar Lad

Which tree should it go through? I can certainly put that into
vfs.git#work.misc, but it looks like a better fit for linux-media tree, or the davinci-specific one...

#3 lore raw
Quoted 10 lines · Al Viro
Quoted 9 lines · Prabhakar
Quoted 8 lines · Al Viro

Passing a physical address to free_pages() is a bad idea.
config_params->fault_pxl.fpc_table_addr is set to virt_to_phys() of __get_free_pages() return value; what we should pass to free_pages() is its phys_to_virt(). ccdc_close() does that properly, but ccdc_update_raw_params() doesn't.

Quoted 8 lines
Quoted 4 lines

Regards,
--Prabhakar Lad

Which tree should it go through? I can certainly put that into
vfs.git#work.misc, but it looks like a better fit for linux-media tree, or the davinci-specific one...

It needs to go linux-media tree I'll issue a pull to mauro soon.

Cheers,
--Prabhakar Lad