[PATCH 11/11] staging: unisys: small bug parser.c

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

 



Fixed small bug in parser.c by removing "cleanups:" in  parser_init
_guts struct.  Replaced it with proper error handling code
and removed the instances of rc = NULL in the code. rc = NULL is
redudant

Signed-off-by: Jeffrey Brown <Jeffrey.Brown@xxxxxxxxxx>
---
 drivers/staging/unisys/visorchipset/parser.c |   46 ++++++-------------------
 1 files changed, 11 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c
index 5f6a7b2..beb36a2 100644
--- a/drivers/staging/unisys/visorchipset/parser.c
+++ b/drivers/staging/unisys/visorchipset/parser.c
@@ -64,8 +64,6 @@ parser_init_guts(u64 addr, u32 bytes, BOOL is_local,
 		       MAX_CONTROLVM_PAYLOAD_BYTES);
 		if (try_again)
 			*try_again = TRUE;
-		rc = NULL;
-		goto cleanups;
 	}
 	ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
 	if (ctx == NULL) {
@@ -73,8 +71,6 @@ parser_init_guts(u64 addr, u32 bytes, BOOL is_local,
 		       __func__, __FILE__, __LINE__, allocbytes);
 		if (try_again)
 			*try_again = TRUE;
-		rc = NULL;
-		goto cleanups;
 	}
 
 	ctx->allocbytes = allocbytes;
@@ -89,42 +85,27 @@ parser_init_guts(u64 addr, u32 bytes, BOOL is_local,
 			ERRDRV("%s - bad local address (0x%-16.16Lx for %lu)",
 			       __func__,
 			       (unsigned long long)addr, (ulong)bytes);
-			rc = NULL;
-			goto cleanups;
 		}
 		p = __va((ulong)(addr));
 		memcpy(ctx->data, p, bytes);
 	} else {
 		rgn = visor_memregion_create(addr, bytes);
-		if (!rgn) {
-			rc = NULL;
-			goto cleanups;
-		}
-		if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
-			rc = NULL;
-			goto cleanups;
-		}
 	}
 	if (!has_standard_payload_header) {
 		ctx->byte_stream = TRUE;
 		rc = ctx;
-		goto cleanups;
 	}
 	phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
 	if (phdr->total_length != bytes) {
 		ERRDRV("%s - bad total length %lu (should be %lu)",
 		       __func__,
 		       (ulong)(phdr->total_length), (ulong)(bytes));
-		rc = NULL;
-		goto cleanups;
 	}
 	if (phdr->total_length < phdr->header_length) {
 		ERRDRV("%s - total length < header length (%lu < %lu)",
 		       __func__,
 		       (ulong)(phdr->total_length),
 		       (ulong)(phdr->header_length));
-		rc = NULL;
-		goto cleanups;
 	}
 	if (phdr->header_length <
 	    sizeof(struct spar_controlvm_parameters_header)) {
@@ -133,25 +114,20 @@ parser_init_guts(u64 addr, u32 bytes, BOOL is_local,
 		       (ulong)(phdr->header_length),
 		       (ulong)(sizeof(
 				struct spar_controlvm_parameters_header)));
-		rc = NULL;
-		goto cleanups;
 	}
 
-	rc = ctx;
-cleanups:
-	if (rgn) {
+out_rgn:
+	if (rgn)
 		visor_memregion_destroy(rgn);
-		rgn = NULL;
-	}
-	if (rc) {
-		controlvm_payload_bytes_buffered += ctx->param_bytes;
-	} else {
-		if (ctx) {
-			parser_done(ctx);
-			ctx = NULL;
-		}
-	}
-	return rc;
+	controlvm_payload_bytes_buffered += ctx->param_bytes;
+
+		return ctx;
+err_rgn:
+	if (rgn)
+		visor_memregion_destroy(rgn);
+err_ctx:
+	kfree(ctx);
+	return NULL;
 }
 
 struct parser_context_tag *
-- 
1.7.1

_______________________________________________
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