* [PATCH] USB: serial: bus: fix const issue in usb_serial_device_match()
@ 2025-05-21 13:41 Greg Kroah-Hartman
2025-05-21 15:09 ` Johan Hovold
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-05-21 13:41 UTC (permalink / raw)
To: linux-usb; +Cc: Greg Kroah-Hartman, Johan Hovold
usb_serial_device_match() takes a const pointer, and then decides to
cast it away into a non-const one, which is not a good thing to do
overall. Fix this up by properly setting the pointers to be const to
preserve that attribute.
Cc: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/serial/bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 2fea1b1db4a2..9e2a18c0b218 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -17,7 +17,7 @@ static int usb_serial_device_match(struct device *dev,
const struct device_driver *drv)
{
const struct usb_serial_port *port = to_usb_serial_port(dev);
- struct usb_serial_driver *driver = to_usb_serial_driver(drv);
+ const struct usb_serial_driver *driver = to_usb_serial_driver(drv);
/*
* drivers are already assigned to ports in serial_probe so it's
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] USB: serial: bus: fix const issue in usb_serial_device_match()
2025-05-21 13:41 [PATCH] USB: serial: bus: fix const issue in usb_serial_device_match() Greg Kroah-Hartman
@ 2025-05-21 15:09 ` Johan Hovold
2025-05-21 15:11 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Johan Hovold @ 2025-05-21 15:09 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb
On Wed, May 21, 2025 at 03:41:34PM +0200, Greg Kroah-Hartman wrote:
> usb_serial_device_match() takes a const pointer, and then decides to
> cast it away into a non-const one, which is not a good thing to do
> overall. Fix this up by properly setting the pointers to be const to
> preserve that attribute.
I think this deserves a Fixes tag as this is a recent issue introduced
by commit d69d80484598 ("driver core: have match() callback in struct
bus_type take a const *") (even if we only use the address of the
pointer).
> Cc: Johan Hovold <johan@kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> @@ -17,7 +17,7 @@ static int usb_serial_device_match(struct device *dev,
> const struct device_driver *drv)
> {
> const struct usb_serial_port *port = to_usb_serial_port(dev);
> - struct usb_serial_driver *driver = to_usb_serial_driver(drv);
> + const struct usb_serial_driver *driver = to_usb_serial_driver(drv);
>
> /*
> * drivers are already assigned to ports in serial_probe so it's
Now applied with a Fixes tag added.
Johan
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] USB: serial: bus: fix const issue in usb_serial_device_match()
2025-05-21 15:09 ` Johan Hovold
@ 2025-05-21 15:11 ` Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-05-21 15:11 UTC (permalink / raw)
To: Johan Hovold; +Cc: linux-usb
On Wed, May 21, 2025 at 05:09:23PM +0200, Johan Hovold wrote:
> On Wed, May 21, 2025 at 03:41:34PM +0200, Greg Kroah-Hartman wrote:
> > usb_serial_device_match() takes a const pointer, and then decides to
> > cast it away into a non-const one, which is not a good thing to do
> > overall. Fix this up by properly setting the pointers to be const to
> > preserve that attribute.
>
> I think this deserves a Fixes tag as this is a recent issue introduced
> by commit d69d80484598 ("driver core: have match() callback in struct
> bus_type take a const *") (even if we only use the address of the
> pointer).
Oops, yes, that is needed, sorry about that.
> > Cc: Johan Hovold <johan@kernel.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> > @@ -17,7 +17,7 @@ static int usb_serial_device_match(struct device *dev,
> > const struct device_driver *drv)
> > {
> > const struct usb_serial_port *port = to_usb_serial_port(dev);
> > - struct usb_serial_driver *driver = to_usb_serial_driver(drv);
> > + const struct usb_serial_driver *driver = to_usb_serial_driver(drv);
> >
> > /*
> > * drivers are already assigned to ports in serial_probe so it's
>
> Now applied with a Fixes tag added.
Great, thanks!
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-21 15:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21 13:41 [PATCH] USB: serial: bus: fix const issue in usb_serial_device_match() Greg Kroah-Hartman
2025-05-21 15:09 ` Johan Hovold
2025-05-21 15:11 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox