[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200211192236.GB1962867@kroah.com>
Date: Tue, 11 Feb 2020 11:22:36 -0800
From: Greg KH <gregkh@...uxfoundation.org>
To: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
Cc: arnd@...db.de, smohanad@...eaurora.org, jhugo@...eaurora.org,
kvalo@...eaurora.org, bjorn.andersson@...aro.org,
hemantk@...eaurora.org, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 02/16] bus: mhi: core: Add support for registering MHI
controllers
On Wed, Feb 12, 2020 at 12:41:47AM +0530, Manivannan Sadhasivam wrote:
> Hi Greg,
>
> On Thu, Feb 06, 2020 at 05:56:06PM +0100, Greg KH wrote:
> > On Fri, Jan 31, 2020 at 07:19:55PM +0530, Manivannan Sadhasivam wrote:
> > > +static void mhi_release_device(struct device *dev)
> > > +{
> > > + struct mhi_device *mhi_dev = to_mhi_device(dev);
> > > +
> > > + if (mhi_dev->ul_chan)
> > > + mhi_dev->ul_chan->mhi_dev = NULL;
> >
> > That looks really odd. Why didn't you just drop the reference you
> > should have grabbed here for this pointer? You did properly increment
> > it when you saved it, right? :)
> >
>
> Well, there is no reference count (kref) exist for mhi_dev.
Then something is wrong with your model :(
You can't save pointers off to things without reference counting, that
is going to cause you real problems. See the coding style document for
all the details.
> And we really needed to NULL the mhi_dev to avoid any dangling
> reference to it.
Again, that's not how to do this correctly.
> The reason for not having kref is that, each mhi_dev will be used by
> maximum of 2 channels only. So thought that refcounting is not needed.
> Please correct me if I'm wrong.
Please read section 11 of Documentation/process/coding-style.rst
thanks,
greg k-h
Powered by blists - more mailing lists