* [PATCH] greybus: gb-beagleplay: fix restricted __le16 degrades to integer warning
@ 2023-11-14 14:01 Ayush Singh
2023-11-14 14:57 ` Alex Elder
0 siblings, 1 reply; 3+ messages in thread
From: Ayush Singh @ 2023-11-14 14:01 UTC (permalink / raw)
To: greybus-dev
Cc: Ayush Singh, johan, elder, gregkh, linux-kernel, kernel test robot
greybus message header->size are of type __le16, so to fix this warnings
we are using le16_to_cpu() macros.
Reported-by: kernel test robot <yujie.liu@intel.com>
Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
---
drivers/greybus/gb-beagleplay.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c
index 43318c1993ba..b3f47b5cbbfa 100644
--- a/drivers/greybus/gb-beagleplay.c
+++ b/drivers/greybus/gb-beagleplay.c
@@ -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));
--
2.41.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] greybus: gb-beagleplay: fix restricted __le16 degrades to integer warning
2023-11-14 14:01 [PATCH] greybus: gb-beagleplay: fix restricted __le16 degrades to integer warning Ayush Singh
@ 2023-11-14 14:57 ` Alex Elder
2023-12-03 7:17 ` Ayush Singh
0 siblings, 1 reply; 3+ messages in thread
From: Alex Elder @ 2023-11-14 14:57 UTC (permalink / raw)
To: Ayush Singh, greybus-dev
Cc: johan, elder, gregkh, linux-kernel, kernel test robot
On 11/14/23 8:01 AM, Ayush Singh wrote:
> greybus message header->size are of type __le16, so to fix this warnings
> we are using le16_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->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
>
> Reported-by: kernel test robot <yujie.liu@intel.com>
> Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/
> Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
> ---
> drivers/greybus/gb-beagleplay.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c
> index 43318c1993ba..b3f47b5cbbfa 100644
> --- a/drivers/greybus/gb-beagleplay.c
> +++ b/drivers/greybus/gb-beagleplay.c
> @@ -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));
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] greybus: gb-beagleplay: fix restricted __le16 degrades to integer warning
2023-11-14 14:57 ` Alex Elder
@ 2023-12-03 7:17 ` Ayush Singh
0 siblings, 0 replies; 3+ messages in thread
From: Ayush Singh @ 2023-12-03 7:17 UTC (permalink / raw)
To: Alex Elder, greybus-dev
Cc: johan, elder, gregkh, linux-kernel, kernel test robot
I 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
On 11/14/23 20:27, Alex Elder wrote:
> On 11/14/23 8:01 AM, Ayush Singh wrote:
>> greybus message header->size are of type __le16, so to fix this warnings
>> we are using le16_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->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
>
>
>
>>
>> Reported-by: kernel test robot <yujie.liu@intel.com>
>> Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/
>> Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
>> ---
>> drivers/greybus/gb-beagleplay.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/greybus/gb-beagleplay.c
>> b/drivers/greybus/gb-beagleplay.c
>> index 43318c1993ba..b3f47b5cbbfa 100644
>> --- a/drivers/greybus/gb-beagleplay.c
>> +++ b/drivers/greybus/gb-beagleplay.c
>> @@ -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));
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-03 7:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-14 14:01 [PATCH] greybus: gb-beagleplay: fix restricted __le16 degrades to integer warning Ayush Singh
2023-11-14 14:57 ` Alex Elder
2023-12-03 7:17 ` Ayush Singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®