lkml.org 
[lkml]   [2024]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] tty: hvc-iucv: fix function pointer casts
On Wed, Feb 14, 2024 at 09:46:33AM +0000, David Laight wrote:
> From: Segher Boessenkool
> > Sent: 13 February 2024 19:13
> >
> > On Tue, Feb 13, 2024 at 11:17:49AM +0100, Arnd Bergmann wrote:
> > > clang warns about explicitly casting between incompatible function
> > > pointers:
> > >
> > > drivers/tty/hvc/hvc_iucv.c:1100:23: error: cast from 'void (*)(const void *)' to 'void (*)(struct
> > device *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
> > > 1100 | priv->dev->release = (void (*)(struct device *)) kfree;
> > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Such a cast of course is explicitly allowed by 6.3.2.3/8, only calling a
> > function using a non-compatible type is UB. This warning message is
> > quite misleading. Doubly so because of the -Werror, as always.
>
> But it will get called using the wrong type.
> And (is it) fine-ibt will reject the incorrect call.

And rightfully so, this type of casting abuse is just that, abuse.

Almost no one should be just calling kfree() on a device pointer, I'll
look at the surrounding code as odds are something odd is going on. But
for now, this patch is correct.

thanks,

greg k-h

\
 
 \ /
  Last update: 2024-05-27 15:02    [W:0.125 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site