[PATCH 048/141] staging: unisys: visorchipset: parser_init_guts(): Localize memregion usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>

Signed-off-by: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>
Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx>
---
 drivers/staging/unisys/visorbus/visorchipset.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 5bf8266..2be8514 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -399,6 +399,7 @@ parser_init_guts(u64 addr, u32 bytes, bool local,
 	struct parser_context *ctx = NULL;
 	struct memregion *rgn = NULL;
 	struct spar_controlvm_parameters_header *phdr = NULL;
+	int cnt;
 
 	if (retry)
 		*retry = false;
@@ -442,7 +443,10 @@ parser_init_guts(u64 addr, u32 bytes, bool local,
 			rc = NULL;
 			goto cleanup;
 		}
-		if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
+		cnt = visor_memregion_read(rgn, 0, ctx->data, bytes);
+		visor_memregion_destroy(rgn);
+
+		if (cnt < 0) {
 			rc = NULL;
 			goto cleanup;
 		}
@@ -469,10 +473,6 @@ parser_init_guts(u64 addr, u32 bytes, bool local,
 
 	rc = ctx;
 cleanup:
-	if (rgn) {
-		visor_memregion_destroy(rgn);
-		rgn = NULL;
-	}
 	if (rc) {
 		controlvm_payload_bytes_buffered += ctx->param_bytes;
 	} else {
-- 
2.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux