mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: John Garry <john.g.garry@oracle.com>,
	Bryam Vargas <hexlabsecurity@proton.me>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Mike Christie <michael.christie@oracle.com>,
	Maurizio Lombardi <mlombard@redhat.com>,
	David Disseldorp <ddiss@suse.de>,
	 linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] scsi: target: copy iSCSI ISID before unmapping the PR OUT buffer
Date: Tue, 09 Jun 2026 07:36:17 -0400	[thread overview]
Message-ID: <239dd72a5ee388486f60eff7e6b025d130e08266.camel@HansenPartnership.com> (raw)
In-Reply-To: <fdb07a39-cf7d-48aa-9e75-1a79dc7ad620@oracle.com>

On Tue, 2026-06-09 at 09:50 +0100, John Garry wrote:
> > @@ -1808,9 +1809,11 @@ core_scsi3_decode_spec_i_port(
> >    		core_scsi3_tpg_undepend_item(dest_tpg);
> >    	}
> > 
> > +	kfree(iport_ptr);
> >    	return 0;
> >    out_unmap:
> >    	transport_kunmap_data_sg(cmd);
> > +	kfree(iport_ptr);
> 
> sorry for suggesting this change, but this is worse than what you had
> originally, as we have so many paths to call kfree() [which means
> more bugs possible]
> 
> it's hard to make good suggestions for this target code as the
> functions are so large and complex.

Given that it's allocated in a function called by the routine but never
actually retained by anything what about defining it as

chat *iport_ptr __free(kfree) = NULL;

?  That way we don't need to care about freeing it in the error legs. 
Even if the value were retained under some conditions, you just signal
retention by setting iport_ptr to NULL to prevent the kfree on exit.

Regards,

James


  reply	other threads:[~2026-06-09 11:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09  0:59 Bryam Vargas
2026-06-09  8:50 ` John Garry
2026-06-09 11:36   ` James Bottomley [this message]
2026-06-09 12:14     ` John Garry
2026-06-09 12:27       ` James Bottomley
2026-06-10  4:22         ` Bryam Vargas

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=239dd72a5ee388486f60eff7e6b025d130e08266.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=ddiss@suse.de \
    --cc=hexlabsecurity@proton.me \
    --cc=john.g.garry@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michael.christie@oracle.com \
    --cc=mlombard@redhat.com \
    --cc=target-devel@vger.kernel.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

all inboxes | Powered by JetHome®