All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Leon Romanovsky <leonro@mellanox.com>
Cc: Zhu Yanjun <yanjun.zhu@oracle.com>,
	saeedm@mellanox.com, matanb@mellanox.com, netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org, yuval.shaia@oracle.com
Subject: Re: [PATCH 1/2] mlx4: remove unnecessary pci_set_drvdata()
Date: Tue, 15 Aug 2017 11:21:49 -0600	[thread overview]
Message-ID: <20170815172149.GC15171@obsidianresearch.com> (raw)
In-Reply-To: <20170815071336.GL24282@mtr-leonro.local>

On Tue, Aug 15, 2017 at 10:13:36AM +0300, Leon Romanovsky wrote:
> On Tue, Aug 15, 2017 at 02:33:05AM -0400, Zhu Yanjun wrote:
> > The driver core clears the driver data to NULL after device_release
> > or on probe failure. Thus, it is not necessary to manually clear the
> > device driver data to NULL.
> >
> 
> It makes sense and I'm pretty sure that you are right, but I'm failing
> to find the function in device core which sets it to NULL. Can you help
> me and present the actual call stack to that code place?

http://elixir.free-electrons.com/linux/v4.13-rc1/source/drivers/base/dd.c#L840

The call to the remove callback is on line 833.

This is done after dropping devres, so you could allocate the drv data
inside a devm object and everything would unwind correctly.

In this case, the kfree is explicit, so I would advocate for still putting
the null near the kfree to minimize the time where a free'd pointer is
present - eg incase a devm callback or some other bug accidently
touches it.

Jason

  reply	other threads:[~2017-08-15 17:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-15  6:33 [PATCH 1/2] mlx4: remove unnecessary pci_set_drvdata() Zhu Yanjun
2017-08-15  7:13 ` Leon Romanovsky
2017-08-15 17:21   ` Jason Gunthorpe [this message]
     [not found]     ` <20170815172149.GC15171-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-08-15 18:00       ` Leon Romanovsky
     [not found] ` <1502778786-14738-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-08-15  6:33   ` [PATCH 2/2] mlx5: " Zhu Yanjun
     [not found]     ` <1502778786-14738-2-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-08-15 23:47       ` David Miller
2017-08-15 23:46   ` [PATCH 1/2] mlx4: " David Miller

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=20170815172149.GC15171@obsidianresearch.com \
    --to=jgunthorpe@obsidianresearch.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=matanb@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=yanjun.zhu@oracle.com \
    --cc=yuval.shaia@oracle.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 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.