Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

greybus: svc: pwrmon: validate svc protocol op status when getting rail names

AP should check for Greybus SVC Protocol Operation Status to determine if the
operation was successfully completed by the SVC

Testing Done:
- Successfully getting the rail names in the pwrmon_dummy sandbox branch

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>

authored by

David Lin and committed by
Greg Kroah-Hartman
8fb76c3c 44d64493

+10 -1
+1
drivers/staging/greybus/greybus_protocols.h
··· 1145 1145 #define GB_SVC_PWRMON_RAIL_NAME_BUFSIZE 32 1146 1146 1147 1147 struct gb_svc_pwrmon_rail_names_get_response { 1148 + __u8 status; 1148 1149 __u8 name[0][GB_SVC_PWRMON_RAIL_NAME_BUFSIZE]; 1149 1150 } __packed; 1150 1151
+9 -1
drivers/staging/greybus/svc.c
··· 135 135 return ret; 136 136 } 137 137 138 + if (response->status != GB_SVC_OP_SUCCESS) { 139 + dev_err(&svc->dev, 140 + "SVC error while getting rail names: %u\n", 141 + response->status); 142 + return -EREMOTEIO; 143 + } 144 + 138 145 return 0; 139 146 } 140 147 ··· 785 778 if (!rail_count || rail_count > GB_SVC_PWRMON_MAX_RAIL_COUNT) 786 779 goto err_pwrmon_debugfs; 787 780 788 - bufsize = GB_SVC_PWRMON_RAIL_NAME_BUFSIZE * rail_count; 781 + bufsize = sizeof(*rail_names) + 782 + GB_SVC_PWRMON_RAIL_NAME_BUFSIZE * rail_count; 789 783 790 784 rail_names = kzalloc(bufsize, GFP_KERNEL); 791 785 if (!rail_names)