greybus: gb-beagleplay: fix restricted __le16 degrades to integer warning
Subsystems (2)
Ayush Singh
maintainerPATCH 1/1 greybus: gb-beagleplay: fix restricted __le16 degrades to integer warning
greybus message header->size are of type __le16, so to fix this warnings we are using le16_to_cpu() macros.
--- drivers/greybus/gb-beagleplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/greybus/gb-beagleplay.c +1 -1
@@ -344,7 +344,7 @@ static int gb_message_send(struct gb_host_device *hd, u16 cport, struct gb_messadev_dbg (&hd->dev,"Sending greybus message with Operation %u, Type: %X on Cport %u" , msg->header->operation_id, msg->header->type, cport); -if (msg->header->size >RX_HDLC_PAYLOAD ) +if (le16_to_cpu (msg->header->size) >RX_HDLC_PAYLOAD )return dev_err_probe (&hd->dev, -E2BIG ,"Greybus message too big" );memcpy (msg->header->pad, &cport,sizeof (cport));
Signature · 1 line
2.41.0
Quoted 2 lines · Ayush Singh
greybus message
header->sizeare of type__le16, so to fix this warnings we are usingle16_to_cpu()macros.
This is more than a warning, it's a bug (though it has no effect with a little-endian native CPU).
I suggest you add:
Should your hdlc_payload->len field be defined as little-endian? I've only scanned through this file at this point but I'm thinking there might be other endianness fixes needed as well.
-Alex
Quoted 21 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Ayush Singh <[email protected]>--- drivers/greybus/gb-beagleplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/greybus/gb-beagleplay.c +1
-1@@ -344,7 +344,7 @@ static int gb_message_send(struct gb_host_device *hd, u16 cport, struct gb_messadev_dbg (&hd->dev,"Sending greybus message with Operation %u, Type: %X on Cport %u" , msg->header->operation_id, msg->header->type, cport); -if (msg->header->size >RX_HDLC_PAYLOAD ) +if (le16_to_cpu (msg->header->size) >RX_HDLC_PAYLOAD )return dev_err_probe (&hd->dev, -E2BIG ,"Greybus message too big" );memcpy (msg->header->pad, &cport,sizeof (cport));
Ayush Singh
maintainerI apologize for the late response (college exams were going on).
I will go through the driver to find if any other endianness fixes are needed.
As for hdlc_payload->len, the whole hdlc_payload is an abstraction to store array length with the actual pointer. The len is never actually sent over HDLC, so it should be fine.
Ayush Singh
Quoted 40 lines · Alex Elder
Quoted 2 lines · Ayush Singh
greybus message
header->sizeare of type__le16, so to fix this warnings we are usingle16_to_cpu()macros.This is more than a warning, it's a bug (though it has no effect with a little-endian native CPU).
I suggest you add:
Fixes ec558bbfea671 ("greybus: Add BeaglePlay Linux Driver")Should your
hdlc_payload->lenfield be defined as little-endian? I've only scanned through this file at this point but I'm thinking there might be other endianness fixes needed as well.-Alex
Quoted 20 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Ayush Singh <[email protected]>---
drivers/greybus/gb-beagleplay.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/greybus/gb-beagleplay.c +1
-0@@ -344,7 +344,7 @@ static int gb_message_send(struct gb_host_device *hd, u16 cport, struct gb_messa dev_dbg(&hd->dev, "Sending greybus message with Operation %u, Type: %X on Cport %u", msg->header->operation_id, msg->header->type, cport); - if (msg->header->size > RX_HDLC_PAYLOAD) + if (le16_to_cpu(msg->header->size) > RX_HDLC_PAYLOAD) return dev_err_probe(&hd->dev, -E2BIG, "Greybus message too big"); memcpy(msg->header->pad, &cport, sizeof(cport));