Skip to content

Commit ec007ef

Browse files
javed-hmartinkpetersen
authored andcommitted
scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases
In fc_disc_gpn_id_resp(), skb is supposed to get freed in all cases except for PTR_ERR. However, in some cases it didn't. This fix is to call fc_frame_free(fp) before function returns. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Girish Basrur <[email protected]> Reviewed-by: Santosh Vernekar <[email protected]> Reviewed-by: Saurav Kashyap <[email protected]> Reviewed-by: Shyam Sundar <[email protected]> Signed-off-by: Javed Hasan <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent e95b478 commit ec007ef

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/scsi/libfc/fc_disc.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,12 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
581581

582582
if (PTR_ERR(fp) == -FC_EX_CLOSED)
583583
goto out;
584-
if (IS_ERR(fp))
585-
goto redisc;
584+
if (IS_ERR(fp)) {
585+
mutex_lock(&disc->disc_mutex);
586+
fc_disc_restart(disc);
587+
mutex_unlock(&disc->disc_mutex);
588+
goto out;
589+
}
586590

587591
cp = fc_frame_payload_get(fp, sizeof(*cp));
588592
if (!cp)
@@ -609,7 +613,7 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
609613
new_rdata->disc_id = disc->disc_id;
610614
fc_rport_login(new_rdata);
611615
}
612-
goto out;
616+
goto free_fp;
613617
}
614618
rdata->disc_id = disc->disc_id;
615619
mutex_unlock(&rdata->rp_mutex);
@@ -626,6 +630,8 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
626630
fc_disc_restart(disc);
627631
mutex_unlock(&disc->disc_mutex);
628632
}
633+
free_fp:
634+
fc_frame_free(fp);
629635
out:
630636
kref_put(&rdata->kref, fc_rport_destroy);
631637
if (!IS_ERR(fp))

0 commit comments

Comments
 (0)