Skip to content

Commit fa519f7

Browse files
hreineckemartinkpetersen
authored andcommitted
scsi: libfc: fixup 'sleeping function called from invalid context'
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>
1 parent ee35624 commit fa519f7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/scsi/libfc/fc_disc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,11 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
287287
* discovery, reverify or log them in. Otherwise, log them out.
288288
* Skip ports which were never discovered. These are the dNS port
289289
* and ports which were created by PLOGI.
290+
*
291+
* We don't need to use the _rcu variant here as the rport list
292+
* is protected by the disc mutex which is already held on entry.
290293
*/
291-
rcu_read_lock();
292-
list_for_each_entry_rcu(rdata, &disc->rports, peers) {
294+
list_for_each_entry(rdata, &disc->rports, peers) {
293295
if (!kref_get_unless_zero(&rdata->kref))
294296
continue;
295297
if (rdata->disc_id) {
@@ -300,7 +302,6 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
300302
}
301303
kref_put(&rdata->kref, fc_rport_destroy);
302304
}
303-
rcu_read_unlock();
304305
mutex_unlock(&disc->disc_mutex);
305306
disc->disc_callback(lport, event);
306307
mutex_lock(&disc->disc_mutex);

0 commit comments

Comments
 (0)