All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Uwe Kleine-König" <uwe@kleine-koenig.org>
Cc: Tomas Winkler <tomas.winkler@intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mei: bus: simplify mei_cl_device_remove()
Date: Mon, 8 Feb 2021 09:22:01 +0100	[thread overview]
Message-ID: <YCD0qdaOG1pb+gPM@kroah.com> (raw)
In-Reply-To: <20210208073705.428185-2-uwe@kleine-koenig.org>

On Mon, Feb 08, 2021 at 08:37:04AM +0100, Uwe Kleine-König wrote:
> The driver core only calls a bus' remove function when there is actually
> a driver and a device. So drop the needless check and assign cldrv earlier.
> 
> (Side note: The check for cldev being non-NULL is broken anyhow, because
> to_mei_cl_device() is a wrapper around container_of() for a member that is
> not the first one. So cldev only can become NULL if dev is (void *)0xc
> (for archs with 32 bit pointers) or (void *)0x18 (for archs with 64 bit
> pointers).)
> 
> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
> ---
>  drivers/misc/mei/bus.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
> index 2907db260fba..50d617e7467e 100644
> --- a/drivers/misc/mei/bus.c
> +++ b/drivers/misc/mei/bus.c
> @@ -878,13 +878,9 @@ static int mei_cl_device_probe(struct device *dev)
>  static int mei_cl_device_remove(struct device *dev)
>  {
>  	struct mei_cl_device *cldev = to_mei_cl_device(dev);
> -	struct mei_cl_driver *cldrv;
> +	struct mei_cl_driver *cldrv = to_mei_cl_driver(dev->driver);
>  	int ret = 0;
>  
> -	if (!cldev || !dev->driver)

Yes, anyone checking that the results of a container_of() wrapper can be
NULL is not checking anything at all :)

thanks for the cleanups, I'll go queue them up.

greg k-h

  reply	other threads:[~2021-02-08  8:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08  7:37 [PATCH v2 0/2] mei: bus: Some cleanups Uwe Kleine-König
2021-02-08  7:37 ` [PATCH v2 1/2] mei: bus: simplify mei_cl_device_remove() Uwe Kleine-König
2021-02-08  8:22   ` Greg Kroah-Hartman [this message]
2021-02-08  7:37 ` [PATCH v2 2/2] mei: bus: change remove callback to return void Uwe Kleine-König

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=YCD0qdaOG1pb+gPM@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=netdev@vger.kernel.org \
    --cc=tomas.winkler@intel.com \
    --cc=uwe@kleine-koenig.org \
    --cc=wim@linux-watchdog.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.