Skip to content

Commit 7a5096c

Browse files
hreineckegregkh
authored andcommitted
scsi: libfc: fixup 'sleeping function called from invalid context'
[ Upstream commit fa519f7 ] fc_rport_login() will be calling mutex_lock() while running inside an RCU-protected section, triggering the warning 'sleeping function called from invalid context'. To fix this we can drop the rcu functions here altogether as the disc mutex protecting the list itself is already held, preventing any list manipulation. Fixes: a407c59 ("scsi: libfc: Fixup disc_mutex handling") Signed-off-by: Hannes Reinecke <hare@suse.com> Acked-by: Johannes Thumshirn <jth@kernel.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c883134 commit 7a5096c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/scsi/libfc/fc_disc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,11 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
294294
* discovery, reverify or log them in. Otherwise, log them out.
295295
* Skip ports which were never discovered. These are the dNS port
296296
* and ports which were created by PLOGI.
297+
*
298+
* We don't need to use the _rcu variant here as the rport list
299+
* is protected by the disc mutex which is already held on entry.
297300
*/
298-
rcu_read_lock();
299-
list_for_each_entry_rcu(rdata, &disc->rports, peers) {
301+
list_for_each_entry(rdata, &disc->rports, peers) {
300302
if (!kref_get_unless_zero(&rdata->kref))
301303
continue;
302304
if (rdata->disc_id) {
@@ -307,7 +309,6 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
307309
}
308310
kref_put(&rdata->kref, fc_rport_destroy);
309311
}
310-
rcu_read_unlock();
311312
mutex_unlock(&disc->disc_mutex);
312313
disc->disc_callback(lport, event);
313314
mutex_lock(&disc->disc_mutex);

0 commit comments

Comments
 (0)