linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: David Laight <David.Laight@aculab.com>
Cc: Arnd Bergmann <arnd@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Jiri Slaby <jirislaby@kernel.org>,
	"llvm@lists.linux.dev" <llvm@lists.linux.dev>,
	Nick Desaulniers <ndesaulniers@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Bill Wendling <morbo@google.com>,
	"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	Justin Stitt <justinstitt@google.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH] tty: hvc-iucv: fix function pointer casts
Date: Wed, 14 Feb 2024 11:37:21 +0100	[thread overview]
Message-ID: <2024021426-unleveled-unhearing-8021@gregkh> (raw)
In-Reply-To: <57d72e2ccc8245fe99982613a11c461c@AcuMS.aculab.com>

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

  reply	other threads:[~2024-02-14 10:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 10:17 [PATCH] tty: hvc-iucv: fix function pointer casts Arnd Bergmann
2024-02-13 19:12 ` Segher Boessenkool
2024-02-14  9:46   ` David Laight
2024-02-14 10:37     ` Greg Kroah-Hartman [this message]
2024-02-14 12:36       ` Segher Boessenkool
2024-02-14  6:25 ` Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2024021426-unleveled-unhearing-8021@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=David.Laight@aculab.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=jirislaby@kernel.org \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).