public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: arvindY <arvind.yadav.cs@gmail.com>
To: Chris Leech <cleech@redhat.com>,
	lduncan@suse.com, jejb@linux.vnet.ibm.com,
	martin.petersen@oracle.com, linux-kernel@vger.kernel.org,
	open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()
Date: Sat, 17 Mar 2018 15:07:52 +0530	[thread overview]
Message-ID: <5AACE1F0.1080109@gmail.com> (raw)
In-Reply-To: <20180315174448.GB32176@straylight.hirudinean.org>



On Thursday 15 March 2018 11:14 PM, Chris Leech wrote:
> On Wed, Mar 07, 2018 at 05:07:33PM +0530, Arvind Yadav wrote:
>> Never directly free @dev after calling device_register(), even
>> if it returned an error! Always use put_device() to give up the
>> reference initialized.
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>>   drivers/scsi/scsi_transport_iscsi.c | 27 +++++++++++++--------------
>>   1 file changed, 13 insertions(+), 14 deletions(-)
>>
>> @@ -783,7 +781,7 @@ struct iscsi_iface *
>>   
>>   free_iface:
>>   	put_device(iface->dev.parent);
>> -	kfree(iface);
>> +	put_device(&iface->dev);
>>   	return NULL;
>>   }
>>   EXPORT_SYMBOL_GPL(iscsi_create_iface);
> Am I reading the device code correctly that the parent reference is only
> released in the unregister path (device_unregister calls device_del) and
> so the manual put_device on the parent here is still correct?
>
> Just want to make sure that's still needed with the call to put_device.
The manual put_device on the parent is not correct.
This should be removed for here. we should call
put_device(&iface->dev) only and It'll released
parent reference.

> Other than that question, I this all looks good.
> Thanks.
>
> Signed-off-by: Chris Leech <cleech@redhat.com>
>

~arvind

      reply	other threads:[~2018-03-17  9:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 11:37 [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree() Arvind Yadav
2018-03-15  4:11 ` Martin K. Petersen
2018-03-15 17:44 ` Chris Leech
2018-03-17  9:37   ` arvindY [this message]

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=5AACE1F0.1080109@gmail.com \
    --to=arvind.yadav.cs@gmail.com \
    --cc=cleech@redhat.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=lduncan@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=open-iscsi@googlegroups.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