arcmsr: fixes not release allocated resource
PATCH v3 2/5 arcmsr: fixes not release allocated resource
From: Ching Huang <[email protected]>
Releasing allocated resource if get configuration data failed.
---
drivers/scsi/arcmsr/arcmsr_hba.c +5 -1
@@ -2664,7 +2664,7 @@ static bool arcmsr_hbaB_get_config(strucif (!arcmsr_hbaB_wait_msgint_ready (acb)) {printk (KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ miscellaneous data' timeout \n" , acb->host->host_no); -return false; + goto err_free_dma; } count =8 ;while (count){
@@ -2707,6 +2707,10 @@ static bool arcmsr_hbaB_get_config(struc acb->firm_cfg_version =readl (®->message_rwbuffer[25 ]);/*firm_cfg_version,25,100-103*/ /*firm_ide_channels,4,16-19*/ return true; +err_free_dma: +dma_free_coherent (&acb->pdev->dev, acb->roundup_ccbsize, + acb->dma_coherent2, acb->dma_coherent_handle2); +return false; }static bool arcmsr_hbaC_get_config (struct AdapterControlBlock *pACB)
Quoted 33 lines · Ching Huang
From: Ching Huang <[email protected]>
Releasing allocated resource if get configuration data failed.
Signed-of-by Ching Huang <[email protected]>---
diff -uprN
a/drivers/scsi/arcmsr/arcmsr_hba.cb/drivers/scsi/arcmsr/arcmsr_hba.c
---a/drivers/scsi/arcmsr/arcmsr_hba.c2015-11-24 11:35:26.000000000
+0800
+++b/drivers/scsi/arcmsr/arcmsr_hba.c2015-11-25 19:04:44.590970000
+0800drivers/scsi/arcmsr/arcmsr_hba.c +0
-0@@ -2664,7 +2664,7 @@ static bool arcmsr_hbaB_get_config(struc if (!arcmsr_hbaB_wait_msgint_ready(acb)) { printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \miscellaneous data' timeout \n", acb->host-
Quoted 1 line
host_no);drivers/scsi/arcmsr/arcmsr_hba.c +1
-1-return false; + goto err_free_dma;}
count = 8;
while (count){(quoted diff) +0
-0@@ -2707,6 +2707,10 @@ static bool arcmsr_hbaB_get_config(struc
acb->firm_cfg_version= readl(®-Quoted 1 line
message_rwbuffer[25]); /*firm_cfg_version,25,100-103*/
/*firm_ide_channels,4,16-19*/
return true;drivers/scsi/arcmsr/arcmsr_hba.c +4
-0+err_free_dma: +dma_free_coherent (&acb->pdev->dev, acb->roundup_ccbsize, + acb->dma_coherent2, acb->dma_coherent_handle2); +return false;
Quoted 5 lines
}
static boolarcmsr_hbaC_get_config(struct AdapterControlBlock *pACB)
Quoted 23 lines · Ching Huang
From: Ching Huang <[email protected]>
Releasing allocated resource if get configuration data failed.
Signed-of-by Ching Huang <[email protected]>---
diff -uprN
a/drivers/scsi/arcmsr/arcmsr_hba.cb/drivers/scsi/arcmsr/arcmsr_hba.cdrivers/scsi/arcmsr/arcmsr_hba.c +1
-1@@ -2664,7 +2664,7 @@ static bool arcmsr_hbaB_get_config(strucif (!arcmsr_hbaB_wait_msgint_ready (acb)) {printk (KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ miscellaneous data' timeout \n" , acb->host->host_no); -return false; + goto err_free_dma; } count =8 ;while (count){
drivers/scsi/arcmsr/arcmsr_hba.c static bool arcmsr_hbaB_get_config(struc · line 2716
Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +4
-0@@ -2707,6 +2707,10 @@ static bool arcmsr_hbaB_get_config(struc acb->firm_cfg_version =readl (®->message_rwbuffer[25 ]);/*firm_cfg_version,25,100-103*/ /*firm_ide_channels,4,16-19*/ return true; +err_free_dma: +dma_free_coherent (&acb->pdev->dev, acb->roundup_ccbsize, + acb->dma_coherent2, acb->dma_coherent_handle2); +return false; }static bool arcmsr_hbaC_get_config (struct AdapterControlBlock *pACB)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Quoted 21 lines · Ching Huang
From: Ching Huang <[email protected]>
Releasing allocated resource if get configuration data failed.
Signed-of-by Ching Huang <[email protected]>---
diff -uprN
a/drivers/scsi/arcmsr/arcmsr_hba.cb/drivers/scsi/arcmsr/arcmsr_hba.cdrivers/scsi/arcmsr/arcmsr_hba.c +1
-1@@ -2664,7 +2664,7 @@ static bool arcmsr_hbaB_get_config(strucif (!arcmsr_hbaB_wait_msgint_ready (acb)) {printk (KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ miscellaneous data' timeout \n" , acb->host->host_no); -return false; + goto err_free_dma; } count =8 ;while (count){
drivers/scsi/arcmsr/arcmsr_hba.c static bool arcmsr_hbaB_get_config(struc · line 2715
Quoted 9 lines
drivers/scsi/arcmsr/arcmsr_hba.c +4
-0@@ -2707,6 +2707,10 @@ static bool arcmsr_hbaB_get_config(struc acb->firm_cfg_version =readl (®->message_rwbuffer[25 ]);/*firm_cfg_version,25,100-103*/ /*firm_ide_channels,4,16-19*/ return true; +err_free_dma: +dma_free_coherent (&acb->pdev->dev, acb->roundup_ccbsize, + acb->dma_coherent2, acb->dma_coherent_handle2); +return false; }
The resource should be released here, that is okay.
How works the resource management when the eh_bus_reset_handler is called ? It looks to me that you allocate a new acb->dma_coherent2 without releasing it before.
Btw. is it needed in that handler to re-read the firmware-spec?
Tomas
Quoted 7 lines
drivers/scsi/arcmsr/arcmsr_hba.c +0
-1static bool arcmsr_hbaC_get_config (struct AdapterControlBlock *pACB) --To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 34 lines · Tomas Henzl
Quoted 21 lines · Ching Huang
From: Ching Huang <[email protected]>
Releasing allocated resource if get configuration data failed.
Signed-of-by Ching Huang <[email protected]>---
diff -uprN
a/drivers/scsi/arcmsr/arcmsr_hba.cb/drivers/scsi/arcmsr/arcmsr_hba.cdrivers/scsi/arcmsr/arcmsr_hba.c +1
-1@@ -2664,7 +2664,7 @@ static bool arcmsr_hbaB_get_config(strucif (!arcmsr_hbaB_wait_msgint_ready (acb)) {printk (KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ miscellaneous data' timeout \n" , acb->host->host_no); -return false; + goto err_free_dma; } count =8 ;while (count){drivers/scsi/arcmsr/arcmsr_hba.c static bool arcmsr_hbaB_get_config(struc · line 2715
Quoted 9 lines
drivers/scsi/arcmsr/arcmsr_hba.c +4
-0@@ -2707,6 +2707,10 @@ static bool arcmsr_hbaB_get_config(struc acb->firm_cfg_version =readl (®->message_rwbuffer[25 ]);/*firm_cfg_version,25,100-103*/ /*firm_ide_channels,4,16-19*/ return true; +err_free_dma: +dma_free_coherent (&acb->pdev->dev, acb->roundup_ccbsize, + acb->dma_coherent2, acb->dma_coherent_handle2); +return false; }The resource should be released here, that is okay.
Quoted 7 lines
How works the resource management when the
eh_bus_reset_handleris called ? It looks to me that you allocate a newacb->dma_coherent2without releasing it before.
Btw. is it needed in that handler to re-read the firmware-spec?Tomas
You are right. In eh_bus_reset_handler, there may re-allocate a new dma resource if call get_config again. I will initiate a new patches for this bug after current 5 patches.
Thanks Tomas.
Quoted 8 lines
Quoted 7 lines
drivers/scsi/arcmsr/arcmsr_hba.c +0
-1static bool arcmsr_hbaC_get_config (struct AdapterControlBlock *pACB) --To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Tomas Henzl
Reviewed-byQuoted 39 lines · Ching Huang
Quoted 38 lines · Tomas Henzl
Quoted 21 lines · Ching Huang
From: Ching Huang <[email protected]>
Releasing allocated resource if get configuration data failed.
Signed-of-by Ching Huang <[email protected]>---
diff -uprN
a/drivers/scsi/arcmsr/arcmsr_hba.cb/drivers/scsi/arcmsr/arcmsr_hba.cdrivers/scsi/arcmsr/arcmsr_hba.c +1
-1@@ -2664,7 +2664,7 @@ static bool arcmsr_hbaB_get_config(strucif (!arcmsr_hbaB_wait_msgint_ready (acb)) {printk (KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ miscellaneous data' timeout \n" , acb->host->host_no); -return false; + goto err_free_dma; } count =8 ;while (count){drivers/scsi/arcmsr/arcmsr_hba.c static bool arcmsr_hbaB_get_config(struc · line 2715
Quoted 9 lines
drivers/scsi/arcmsr/arcmsr_hba.c +4
-0@@ -2707,6 +2707,10 @@ static bool arcmsr_hbaB_get_config(struc acb->firm_cfg_version =readl (®->message_rwbuffer[25 ]);/*firm_cfg_version,25,100-103*/ /*firm_ide_channels,4,16-19*/ return true; +err_free_dma: +dma_free_coherent (&acb->pdev->dev, acb->roundup_ccbsize, + acb->dma_coherent2, acb->dma_coherent_handle2); +return false; }The resource should be released here, that is okay.
How works the resource management when the
eh_bus_reset_handleris called ? It looks to me that you allocate a newacb->dma_coherent2without releasing it before.
Btw. is it needed in that handler to re-read the firmware-spec?
Quoted 5 lines
Quoted 2 lines
Tomas
You are right. In
eh_bus_reset_handler, there may re-allocate a new dma resource if callget_configagain. I will initiate a new patches for this bug after current 5 patches.
Thanks Tomas.
ok, so for this patch -
Tomas