[PATCH 1/1] staging: unisys: small parser.c bug fix
Jeffrey Brown
Jeffrey.Brown at unisys.com
Fri Nov 14 15:03:30 UTC 2014
Replaced "cleanups" in the struct parser_init_guts with err_rgn,
err_ctx, and out_rgn. The purpose is to remove redundant code and
have proper error handling. Put "goto out_rgn" on lin 108 because
there was no "out_ctx".
Signed-off-by: Jeffrey Brown <Jeffrey.Brown at unisys.com>
---
drivers/staging/unisys/visorchipset/parser.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c
index 2897125..d31c856 100644
--- a/drivers/staging/unisys/visorchipset/parser.c
+++ b/drivers/staging/unisys/visorchipset/parser.c
@@ -71,7 +71,6 @@ parser_init_guts(u64 addr, u32 bytes, BOOL is_local,
__func__, __FILE__, __LINE__, allocbytes);
if (try_again)
*try_again = TRUE;
- rc = NULL;
return NULL;
}
@@ -87,40 +86,41 @@ 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;
+ return NULL;
+ goto err_ctx;
}
p = __va((ulong)(addr));
memcpy(ctx->data, p, bytes);
} else {
rgn = visor_memregion_create(addr, bytes);
if (!rgn) {
- rc = NULL;
+ return NULL;
goto err_ctx;
}
if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
- rc = NULL;
+ return NULL;
goto err_ctx;
}
}
if (!has_standard_payload_header) {
ctx->byte_stream = TRUE;
rc = ctx;
- goto err_rgn;
+ goto out_rgn;
}
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 out_rgn;
+ return NULL;
+ goto err_rgn;
}
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;
+ return NULL;
goto err_rgn;
}
if (phdr->header_length <
@@ -130,7 +130,7 @@ parser_init_guts(u64 addr, u32 bytes, BOOL is_local,
(ulong)(phdr->header_length),
(ulong)(sizeof(
struct spar_controlvm_parameters_header)));
- rc = NULL;
+ return NULL;
goto err_rgn;
}
@@ -138,7 +138,8 @@ out_rgn:
if (rgn)
visor_memregion_destroy(rgn);
- return ctx;
+ controlvm_payload_bytes_buffered += ctx->param_bytes;
+ return ctx;
err_rgn:
if (rgn)
--
1.8.4
More information about the devel
mailing list