linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall-L2FTfq7BK8M@public.gmane.org>
To: Jingoo Han <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Cc: 'Mark Brown' <broonie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: devm_spi_register_master
Date: Mon, 11 Nov 2013 19:18:55 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.02.1311111915570.2321@hadrien> (raw)
In-Reply-To: <002701cedf3b$19f5b280$4de11780$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

On Tue, 12 Nov 2013, Jingoo Han wrote:

> On Tuesday, November 12, 2013 2:45 AM, Julia Lawall wrote:
> >
> > Hello,
> >
> > I was looking into the use of devm_spi_register_master.  This function
> > seems to take care of registering and unregistering, but not allocation
> > and freeing.  I have the impression that that is done with
> > spi_alloc_master and and spi_master_put, which are not managed functions.
> > But then I wonder how this can work?  It seems that the spi_master_put
> > function should remain in the probe or remove function, and then the
> > object could be freed before it is unregistered?
> >
> > The patch 2fe7e4add3e53df7c1b97e32076f8390dd81c6b3 introduces a call to
> > devm_spi_register_master and also removes a call to spi_master_put.  By my
> > reasoning, this would cause a memory leak.
>
> Hi Julia Lawall,
>
> I already checked that the patch 2fe7e4a "spi: txx9: use
> devm_spi_register_master()" is right. The call to spi_master_put()
> was duplicated. So, it should be removed.
>
> When removing the driver, the following functions are called.
> : devm_spi_unregister()
>        -> spi_unregister_master()
>            -> device_unregister()
>                -> put_device()
>
> Also, spi_master_put() calls the following functions.
> : spi_master_put()
>        -> put_device()
>
> So, put_device() is duplicated, when devm_spi_register_master()
> is used. In this case, spi_master_put() can be removed.

spi_register_master calls device_add, which seems to increment the
reference count.  So it may be that both calls to put_device are needed.
On the other hand, in that case it would be safe to invert their order.

julia

> Mark,
> If I am wrong, please let me know kindly. :-)
>
> Best regards,
> Jingoo Han
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-11-12  3:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-11 17:44 devm_spi_register_master Julia Lawall
2013-11-12  0:06 ` devm_spi_register_master Jingoo Han
     [not found]   ` <002701cedf3b$19f5b280$4de11780$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-11-12  3:18     ` Julia Lawall [this message]
2013-11-12  6:48       ` devm_spi_register_master Jingoo Han
     [not found]         ` <000301cedf73$2ae7a3e0$80b6eba0$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-11-22  2:13           ` devm_spi_register_master Jingoo Han
2013-11-15  8:24       ` devm_spi_register_master Jingoo Han
     [not found]         ` <000e01cee1dc$12a4fba0$37eef2e0$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-11-15  8:49           ` devm_spi_register_master Wei Yongjun
     [not found]             ` <CAPgLHd9hFNuke_cfs9QrQ0E0E_QmRfN3=fESUtBH6PPGgx=Wbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-16 16:05               ` devm_spi_register_master Julia Lawall
2013-11-16 10:50 ` devm_spi_register_master Mark Brown
     [not found]   ` <20131116105029.GN15393-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-16 15:24     ` devm_spi_register_master Julia Lawall
2013-11-16 15:45       ` devm_spi_register_master Mark Brown

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=alpine.DEB.2.02.1311111915570.2321@hadrien \
    --to=julia.lawall-l2ftfq7bk8m@public.gmane.org \
    --cc=broonie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 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).