Skip to content

Commit 4f419fd

Browse files
javed-hgregkh
authored andcommitted
scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases
[ Upstream commit ec007ef ] 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/20200729081824.30996-2-jhasan@marvell.com Reviewed-by: Girish Basrur <gbasrur@marvell.com> Reviewed-by: Santosh Vernekar <svernekar@marvell.com> Reviewed-by: Saurav Kashyap <skashyap@marvell.com> Reviewed-by: Shyam Sundar <ssundar@marvell.com> Signed-off-by: Javed Hasan <jhasan@marvell.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 62646cb commit 4f419fd

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/scsi/libfc/fc_disc.c

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

594594
if (PTR_ERR(fp) == -FC_EX_CLOSED)
595595
goto out;
596-
if (IS_ERR(fp))
597-
goto redisc;
596+
if (IS_ERR(fp)) {
597+
mutex_lock(&disc->disc_mutex);
598+
fc_disc_restart(disc);
599+
mutex_unlock(&disc->disc_mutex);
600+
goto out;
601+
}
598602

599603
cp = fc_frame_payload_get(fp, sizeof(*cp));
600604
if (!cp)
@@ -621,7 +625,7 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
621625
new_rdata->disc_id = disc->disc_id;
622626
fc_rport_login(new_rdata);
623627
}
624-
goto out;
628+
goto free_fp;
625629
}
626630
rdata->disc_id = disc->disc_id;
627631
mutex_unlock(&rdata->rp_mutex);
@@ -638,6 +642,8 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
638642
fc_disc_restart(disc);
639643
mutex_unlock(&disc->disc_mutex);
640644
}
645+
free_fp:
646+
fc_frame_free(fp);
641647
out:
642648
kref_put(&rdata->kref, fc_rport_destroy);
643649
if (!IS_ERR(fp))

0 commit comments

Comments
 (0)