Skip to contentSkip to conversation

scsi: pmcraid: Add missing resource releases

PATCH Applied Quentin Lambert 3 participants 3 messages Nov 19, 2016 – Nov 22, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: pmcraid: Add missing resource releases

Most error branches following the call to pmcraid_get_free_cmd contain a call to pmcraid_return_cmd. This patch add these calls where they are missing.

Moreover, most error branches following the call to class_create contain a call to class_destroy. This patch add these calls where they are missing.

This issue was found with Hector.

---
 drivers/scsi/pmcraid.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/scsi/pmcraid.c +7 -3
@@ -3787,11 +3787,11 @@ static long pmcraid_ioctl_passthrough(
 						      direction);
 		if (rc) {
 			pmcraid_err("couldn't build passthrough ioadls\n");
-			goto out_free_buffer;
+			goto out_free_cmd;
 		}
 	} else if (request_size < 0) {
 		rc = -EINVAL;
-		goto out_free_buffer;
+		goto out_free_cmd;
 	}
 
 	/* If data is being written into the device, copy the data from user
@@ -3908,6 +3908,8 @@ out_handle_response:
 
 out_free_sglist:
 	pmcraid_release_passthrough_ioadls(cmd, request_size, direction);
+
+out_free_cmd:
 	pmcraid_return_cmd(cmd);
 
 out_free_buffer:
@@ -6018,8 +6020,10 @@ static int __init pmcraid_init(void)
 
 	error = pmcraid_netlink_init();
 
-	if (error)
+	if (error) {
+		class_destroy(pmcraid_class);
 		goto out_unreg_chrdev;
+	}
 
 	error = pci_register_driver(&pmcraid_driver);
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Quentin Lambert

Most error branches following the call to pmcraid_get_free_cmd contain a call to pmcraid_return_cmd. This patch add these calls where they are missing.

Moreover, most error branches following the call to class_create contain a call to class_destroy. This patch add these calls where they are missing.

This issue was found with Hector.

Looks good,

Tomas

Quoted 46 lines
---
 drivers/scsi/pmcraid.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/scsi/pmcraid.c +7 -4
@@ -3787,11 +3787,11 @@ static long pmcraid_ioctl_passthrough(
 						      direction);
 		if (rc) {
 			pmcraid_err("couldn't build passthrough ioadls\n");
-			goto out_free_buffer;
+			goto out_free_cmd;
 		}
 	} else if (request_size < 0) {
 		rc = -EINVAL;
-		goto out_free_buffer;
+		goto out_free_cmd;
 	}
 
 	/* If data is being written into the device, copy the data from user
@@ -3908,6 +3908,8 @@ out_handle_response:
 
 out_free_sglist:
 	pmcraid_release_passthrough_ioadls(cmd, request_size, direction);
+
+out_free_cmd:
 	pmcraid_return_cmd(cmd);
 
 out_free_buffer:
@@ -6018,8 +6020,10 @@ static int __init pmcraid_init(void)
 
 	error = pmcraid_netlink_init();
 
-	if (error)
+	if (error) {
+		class_destroy(pmcraid_class);
 		goto out_unreg_chrdev;
+	}
 
 	error = pci_register_driver(&pmcraid_driver);
 
--

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

#2 lore raw
In reply to Quentin Lambert
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Quentin" = Quentin Lambert <[email protected]> writes:

Quentin> Most error branches following the call to pmcraid_get_free_cmd Quentin> contain a call to pmcraid_return_cmd. This patch add these Quentin> calls where they are missing.

Quentin> Moreover, most error branches following the call to Quentin> class_create contain a call to class_destroy. This patch add Quentin> these calls where they are missing.

Applied to 4.10/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering