On 4/17/23 12:18 PM, Maurizio Lombardi wrote: > The tpg->np_login_sem is a semaphore that is used to serialize the login > process when multiple login threads run concurrently against the same > target portal group. > > The iscsi_target_locate_portal() function finds the tpg, > calls iscsit_access_np() against the np_login_sem semaphore > and saves the tpg pointer in conn->tpg; > > If iscsi_target_locate_portal() fails, the caller will check for the > conn->tpg pointer and, if it's not NULL, then it will assume > that iscsi_target_locate_portal() called iscsit_access_np() on the > semaphore. > > Make sure that conn->tpg gets initialized only if iscsit_access_np() > was successful, otherwise iscsit_deaccess_np() may end up > being called against a semaphore we never took, allowing more than one > thread to access the same tpg. > > Signed-off-by: Maurizio Lombardi <mlombard@xxxxxxxxxx> Reviewed-by: Mike Christie <michael.christie@xxxxxxxxxx>