public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: typec: fix const issue in typec_match()
@ 2025-05-21 13:41 Greg Kroah-Hartman
  2025-05-22 12:05 ` Heikki Krogerus
  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, Heikki Krogerus

typec_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: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/typec/bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
index ae90688d23e4..91eae95d6fa4 100644
--- a/drivers/usb/typec/bus.c
+++ b/drivers/usb/typec/bus.c
@@ -449,8 +449,8 @@ ATTRIBUTE_GROUPS(typec);
 
 static int typec_match(struct device *dev, const struct device_driver *driver)
 {
-	struct typec_altmode_driver *drv = to_altmode_driver(driver);
-	struct typec_altmode *altmode = to_typec_altmode(dev);
+	const struct typec_altmode_driver *drv = to_altmode_driver(driver);
+	const struct typec_altmode *altmode = to_typec_altmode(dev);
 	const struct typec_device_id *id;
 
 	for (id = drv->id_table; id->svid; id++)
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] USB: typec: fix const issue in typec_match()
  2025-05-21 13:41 [PATCH] USB: typec: fix const issue in typec_match() Greg Kroah-Hartman
@ 2025-05-22 12:05 ` Heikki Krogerus
  2025-05-22 12:30   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Heikki Krogerus @ 2025-05-22 12:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb

Hi Greg,

On Wed, May 21, 2025 at 03:41:27PM +0200, Greg Kroah-Hartman wrote:
> typec_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: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Shouldn't there be a Fixes tag? git blame gives commit d69d804845985

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

thanks,

> ---
>  drivers/usb/typec/bus.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
> index ae90688d23e4..91eae95d6fa4 100644
> --- a/drivers/usb/typec/bus.c
> +++ b/drivers/usb/typec/bus.c
> @@ -449,8 +449,8 @@ ATTRIBUTE_GROUPS(typec);
>  
>  static int typec_match(struct device *dev, const struct device_driver *driver)
>  {
> -	struct typec_altmode_driver *drv = to_altmode_driver(driver);
> -	struct typec_altmode *altmode = to_typec_altmode(dev);
> +	const struct typec_altmode_driver *drv = to_altmode_driver(driver);
> +	const struct typec_altmode *altmode = to_typec_altmode(dev);
>  	const struct typec_device_id *id;
>  
>  	for (id = drv->id_table; id->svid; id++)
> -- 
> 2.49.0
> 

-- 
heikki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] USB: typec: fix const issue in typec_match()
  2025-05-22 12:05 ` Heikki Krogerus
@ 2025-05-22 12:30   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-05-22 12:30 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: linux-usb

On Thu, May 22, 2025 at 03:05:51PM +0300, Heikki Krogerus wrote:
> Hi Greg,
> 
> On Wed, May 21, 2025 at 03:41:27PM +0200, Greg Kroah-Hartman wrote:
> > typec_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: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> Shouldn't there be a Fixes tag? git blame gives commit d69d804845985

Yes, as Johan pointed out, this is my fault :)  I'll add that when I
commit this.

> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

thanks for the review!

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-22 12:30 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: typec: fix const issue in typec_match() Greg Kroah-Hartman
2025-05-22 12:05 ` Heikki Krogerus
2025-05-22 12:30   ` 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