staging: greybus: power_supply: fix prop-descriptor request size
Subsystems (4)
Johan Hovold
maintainerPATCH 1/1 staging: greybus: power_supply: fix prop-descriptor request size
Since moving the message buffers off the stack, the dynamically allocated get-prop-descriptor request buffer is incorrectly sized due to using the pointer rather than request-struct size when creating the operation.
Fortunately, the pointer size is always larger than this one-byte request, but this could still cause trouble on the remote end due to the unexpected message size.
--- drivers/staging/greybus/power_supply.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/power_supply.c +1 -1
@@ -520,7 +520,7 @@ static int gb_power_supply_prop_descriptors_get(struct gb_power_supply *gbpsy) op =gb_operation_create (connection,GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS , -sizeof (req),sizeof (*resp) + props_count * +sizeof (*req),sizeof (*resp) + props_count *sizeof (struct gb_power_supply_props_desc ),GFP_KERNEL );if (!op)
Signature · 1 line
2.21.0
Hi Johan,
Thanks for the patch.
Quoted 5 lines · Johan Hovold
Since moving the message buffers off the stack, the dynamically allocated get-prop-descriptor request buffer is incorrectly sized due to using the pointer rather than request-struct size when creating the operation.
Quoted 8 lines
Fortunately, the pointer size is always larger than this one-byte request, but this could still cause trouble on the remote end due to the unexpected message size.
Fixes 9d15134d067e ("greybus: power_supply: rework get descriptors")Cc stable <[email protected]> # 4.9Cc Rui Miguel Silva <[email protected]>Signed-off-by Johan Hovold <[email protected]>
Nice catch. LGTM.
---
Cheers,
Rui
Quoted 21 lines
--- drivers/staging/greybus/power_supply.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/greybus/power_supply.c +0
-1@@ -520,7 +520,7 @@ static int gb_power_supply_prop_descriptors_get(struct gb_power_supply *gbpsy) op = gb_operation_create(connection, GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS, - sizeof(req), sizeof(*resp) +
props_count*drivers/staging/greybus/power_supply.c +1
-0+ sizeof(*req), sizeof(*resp) +
props_count*drivers/staging/greybus/power_supply.c +0
-0sizeof (struct gb_power_supply_props_desc ), GFP_KERNEL);if (!op)