aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/sbp
diff options
context:
space:
mode:
authorChris Boot <bootc@bootc.net>2012-12-11 16:58:48 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2012-12-13 00:17:25 -0500
commite1fe2060d7e8f58a69374135e32e90f0bb79a7fd (patch)
tree496e995322db60717dbf31ca84f9d8753f125479 /drivers/target/sbp
parent37419d674ca99739dbee5ada28b50aacc29c94e1 (diff)
sbp-target: fix error path in sbp_make_tpg()
If the TPG memory is allocated successfully, but we fail further along in the function, a dangling pointer to freed memory is left in the TPort structure. This is mostly harmless, but does prevent re-trying the operation without first removing the TPort altogether. Reported-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Chris Boot <bootc@bootc.net> Cc: Andy Grover <agrover@redhat.com> Cc: Nicholas A. Bellinger <nab@linux-iscsi.org> Cc: stable@vger.kernel.org Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/sbp')
-rw-r--r--drivers/target/sbp/sbp_target.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index f0a2a1d982a2..2e8d06f198ae 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -2208,20 +2208,23 @@ static struct se_portal_group *sbp_make_tpg(
2208 tport->mgt_agt = sbp_management_agent_register(tport); 2208 tport->mgt_agt = sbp_management_agent_register(tport);
2209 if (IS_ERR(tport->mgt_agt)) { 2209 if (IS_ERR(tport->mgt_agt)) {
2210 ret = PTR_ERR(tport->mgt_agt); 2210 ret = PTR_ERR(tport->mgt_agt);
2211 kfree(tpg); 2211 goto out_free_tpg;
2212 return ERR_PTR(ret);
2213 } 2212 }
2214 2213
2215 ret = core_tpg_register(&sbp_fabric_configfs->tf_ops, wwn, 2214 ret = core_tpg_register(&sbp_fabric_configfs->tf_ops, wwn,
2216 &tpg->se_tpg, (void *)tpg, 2215 &tpg->se_tpg, (void *)tpg,
2217 TRANSPORT_TPG_TYPE_NORMAL); 2216 TRANSPORT_TPG_TYPE_NORMAL);
2218 if (ret < 0) { 2217 if (ret < 0)
2219 sbp_management_agent_unregister(tport->mgt_agt); 2218 goto out_unreg_mgt_agt;
2220 kfree(tpg);
2221 return ERR_PTR(ret);
2222 }
2223 2219
2224 return &tpg->se_tpg; 2220 return &tpg->se_tpg;
2221
2222out_unreg_mgt_agt:
2223 sbp_management_agent_unregister(tport->mgt_agt);
2224out_free_tpg:
2225 tport->tpg = NULL;
2226 kfree(tpg);
2227 return ERR_PTR(ret);
2225} 2228}
2226 2229
2227static void sbp_drop_tpg(struct se_portal_group *se_tpg) 2230static void sbp_drop_tpg(struct se_portal_group *se_tpg)