Re: [PATCH v2] scsi: target: copy iSCSI ISID before unmapping the PR OUT buffer
James Bottomley <[email protected]> Tue, 09 Jun 2026 07:36:17 -0400
| Newsgroups | org.kernel.vger.target-devel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-scsi |
|---|---|
| Message-ID | <239dd72a5ee388486f60eff7e6b025d130e08266.camel@HansenPartnership.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