* re: usb: musb: omap: Add device tree support for omap musb glue
@ 2014-06-10 19:02 Dan Carpenter
2014-06-13 11:11 ` Kishon Vijay Abraham I
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2014-06-10 19:02 UTC (permalink / raw)
To: kishon; +Cc: linux-omap
Hello Kishon Vijay Abraham I,
The patch 00a0b1d58af873d8: "usb: musb: omap: Add device tree support
for omap musb glue", from Sep 11 2012, leads to the following static
checker warning:
drivers/usb/musb/omap2430.c:569 omap2430_probe()
warn: does endianness matter for 'config->num_eps'?
drivers/usb/musb/omap2430.c
565
566 of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
567 of_property_read_u32(np, "interface-type",
568 (u32 *)&data->interface_type);
569 of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps);
^^^^^^^^^^^^^^^
This is not endian safe, but more importantly ->num_eps is a u8 so when
we write 32 bits to it, we are corrupting ->dma_channels,
->dyn_fifo_size, and ->vendor_ctrl. On little endian, it's going to be
setting them to zero so it might not cause and immediate problem.
The way to do this is to use a 32 bit temporary variable and then save
the value to ->num_eps afterward. Create a small function to do this in
a nice way.
All the casts here are a bit scary.
570 of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);
571 of_property_read_u32(np, "power", (u32 *)&pdata->power);
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: usb: musb: omap: Add device tree support for omap musb glue
2014-06-10 19:02 usb: musb: omap: Add device tree support for omap musb glue Dan Carpenter
@ 2014-06-13 11:11 ` Kishon Vijay Abraham I
0 siblings, 0 replies; 2+ messages in thread
From: Kishon Vijay Abraham I @ 2014-06-13 11:11 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-omap
Hi,
On Wednesday 11 June 2014 12:32 AM, Dan Carpenter wrote:
> Hello Kishon Vijay Abraham I,
>
> The patch 00a0b1d58af873d8: "usb: musb: omap: Add device tree support
> for omap musb glue", from Sep 11 2012, leads to the following static
> checker warning:
>
> drivers/usb/musb/omap2430.c:569 omap2430_probe()
> warn: does endianness matter for 'config->num_eps'?
>
> drivers/usb/musb/omap2430.c
> 565
> 566 of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
> 567 of_property_read_u32(np, "interface-type",
> 568 (u32 *)&data->interface_type);
> 569 of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps);
> ^^^^^^^^^^^^^^^
>
> This is not endian safe, but more importantly ->num_eps is a u8 so when
> we write 32 bits to it, we are corrupting ->dma_channels,
> ->dyn_fifo_size, and ->vendor_ctrl. On little endian, it's going to be
> setting them to zero so it might not cause and immediate problem.
>
> The way to do this is to use a 32 bit temporary variable and then save
> the value to ->num_eps afterward. Create a small function to do this in
> a nice way.
Sure. Will do it.
Thanks
Kishon
>
> All the casts here are a bit scary.
>
> 570 of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);
> 571 of_property_read_u32(np, "power", (u32 *)&pdata->power);
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-13 11:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-10 19:02 usb: musb: omap: Add device tree support for omap musb glue Dan Carpenter
2014-06-13 11:11 ` Kishon Vijay Abraham I
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).