aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2016-07-16 07:43:44 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-07-29 14:36:52 -0400
commit1a8e5f28c9cd9c5e1daa04e33cdb4a1038c2aaee (patch)
treec80833146b723bb0b802c23113fe13c6eb623b50 /drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
parent1721c69c3300f39ea63c7b551764873bb7ac83d1 (diff)
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: Christian König <christian.koenig@amd.com> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index 4cd857ff73ff..e45b5b512920 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -915,8 +915,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
915 acpi_handle handle; 915 acpi_handle handle;
916 struct acpi_object_list input; 916 struct acpi_object_list input;
917 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 917 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
918 union acpi_object *params = NULL; 918 union acpi_object *params, *obj;
919 union acpi_object *obj = NULL;
920 uint8_t name[5] = {'\0'}; 919 uint8_t name[5] = {'\0'};
921 struct cgs_acpi_method_argument *argument = NULL; 920 struct cgs_acpi_method_argument *argument = NULL;
922 uint32_t i, count; 921 uint32_t i, count;
@@ -1008,7 +1007,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
1008 1007
1009 if (ACPI_FAILURE(status)) { 1008 if (ACPI_FAILURE(status)) {
1010 result = -EIO; 1009 result = -EIO;
1011 goto error; 1010 goto free_input;
1012 } 1011 }
1013 1012
1014 /* return the output info */ 1013 /* return the output info */
@@ -1018,7 +1017,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
1018 if ((obj->type != ACPI_TYPE_PACKAGE) || 1017 if ((obj->type != ACPI_TYPE_PACKAGE) ||
1019 (obj->package.count != count)) { 1018 (obj->package.count != count)) {
1020 result = -EIO; 1019 result = -EIO;
1021 goto error; 1020 goto free_obj;
1022 } 1021 }
1023 params = obj->package.elements; 1022 params = obj->package.elements;
1024 } else 1023 } else
@@ -1026,13 +1025,13 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
1026 1025
1027 if (params == NULL) { 1026 if (params == NULL) {
1028 result = -EIO; 1027 result = -EIO;
1029 goto error; 1028 goto free_obj;
1030 } 1029 }
1031 1030
1032 for (i = 0; i < count; i++) { 1031 for (i = 0; i < count; i++) {
1033 if (argument->type != params->type) { 1032 if (argument->type != params->type) {
1034 result = -EIO; 1033 result = -EIO;
1035 goto error; 1034 goto free_obj;
1036 } 1035 }
1037 switch (params->type) { 1036 switch (params->type) {
1038 case ACPI_TYPE_INTEGER: 1037 case ACPI_TYPE_INTEGER:
@@ -1042,7 +1041,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
1042 if ((params->string.length != argument->data_length) || 1041 if ((params->string.length != argument->data_length) ||
1043 (params->string.pointer == NULL)) { 1042 (params->string.pointer == NULL)) {
1044 result = -EIO; 1043 result = -EIO;
1045 goto error; 1044 goto free_obj;
1046 } 1045 }
1047 strncpy(argument->pointer, 1046 strncpy(argument->pointer,
1048 params->string.pointer, 1047 params->string.pointer,
@@ -1051,7 +1050,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
1051 case ACPI_TYPE_BUFFER: 1050 case ACPI_TYPE_BUFFER:
1052 if (params->buffer.pointer == NULL) { 1051 if (params->buffer.pointer == NULL) {
1053 result = -EIO; 1052 result = -EIO;
1054 goto error; 1053 goto free_obj;
1055 } 1054 }
1056 memcpy(argument->pointer, 1055 memcpy(argument->pointer,
1057 params->buffer.pointer, 1056 params->buffer.pointer,
@@ -1064,8 +1063,9 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device,
1064 params++; 1063 params++;
1065 } 1064 }
1066 1065
1067error: 1066free_obj:
1068 kfree(obj); 1067 kfree(obj);
1068free_input:
1069 kfree((void *)input.pointer); 1069 kfree((void *)input.pointer);
1070 return result; 1070 return result;
1071} 1071}