Commit 1a8e5f28 authored by Markus Elfring's avatar Markus Elfring Committed by Alex Deucher

drm/amdgpu: One function call less in amdgpu_cgs_acpi_eval_object() after error detection

The kfree() function was called in one case by the
amdgpu_cgs_acpi_eval_object() function during error handling
even if the passed variable "obj" contained a null pointer.

* Adjust jump targets according to the Linux coding style convention.

* Delete unnecessary initialisations for the variables "obj"
  and "params" then.
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1721c69c
...@@ -915,8 +915,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, ...@@ -915,8 +915,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
acpi_handle handle; acpi_handle handle;
struct acpi_object_list input; struct acpi_object_list input;
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *params = NULL; union acpi_object *params, *obj;
union acpi_object *obj = NULL;
uint8_t name[5] = {'\0'}; uint8_t name[5] = {'\0'};
struct cgs_acpi_method_argument *argument = NULL; struct cgs_acpi_method_argument *argument = NULL;
uint32_t i, count; uint32_t i, count;
...@@ -1008,7 +1007,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, ...@@ -1008,7 +1007,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
result = -EIO; result = -EIO;
goto error; goto free_input;
} }
/* return the output info */ /* return the output info */
...@@ -1018,7 +1017,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, ...@@ -1018,7 +1017,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
if ((obj->type != ACPI_TYPE_PACKAGE) || if ((obj->type != ACPI_TYPE_PACKAGE) ||
(obj->package.count != count)) { (obj->package.count != count)) {
result = -EIO; result = -EIO;
goto error; goto free_obj;
} }
params = obj->package.elements; params = obj->package.elements;
} else } else
...@@ -1026,13 +1025,13 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, ...@@ -1026,13 +1025,13 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
if (params == NULL) { if (params == NULL) {
result = -EIO; result = -EIO;
goto error; goto free_obj;
} }
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (argument->type != params->type) { if (argument->type != params->type) {
result = -EIO; result = -EIO;
goto error; goto free_obj;
} }
switch (params->type) { switch (params->type) {
case ACPI_TYPE_INTEGER: case ACPI_TYPE_INTEGER:
...@@ -1042,7 +1041,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, ...@@ -1042,7 +1041,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
if ((params->string.length != argument->data_length) || if ((params->string.length != argument->data_length) ||
(params->string.pointer == NULL)) { (params->string.pointer == NULL)) {
result = -EIO; result = -EIO;
goto error; goto free_obj;
} }
strncpy(argument->pointer, strncpy(argument->pointer,
params->string.pointer, params->string.pointer,
...@@ -1051,7 +1050,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, ...@@ -1051,7 +1050,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
case ACPI_TYPE_BUFFER: case ACPI_TYPE_BUFFER:
if (params->buffer.pointer == NULL) { if (params->buffer.pointer == NULL) {
result = -EIO; result = -EIO;
goto error; goto free_obj;
} }
memcpy(argument->pointer, memcpy(argument->pointer,
params->buffer.pointer, params->buffer.pointer,
...@@ -1064,8 +1063,9 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, ...@@ -1064,8 +1063,9 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
params++; params++;
} }
error: free_obj:
kfree(obj); kfree(obj);
free_input:
kfree((void *)input.pointer); kfree((void *)input.pointer);
return result; return result;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment