diff options
author | Dan Carpenter <error27@gmail.com> | 2011-06-15 12:41:33 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-06-23 20:03:27 -0400 |
commit | 552523dcbf0f33d44d816da310be8227a2c1502a (patch) | |
tree | b3068ed11f76b583996b59f001d68bcc4be25156 /drivers/target/loopback/tcm_loop.c | |
parent | 233888644d80cc44330062e5e978c9e3a14c9cb9 (diff) |
target: Fix ERR_PTR dereferencing bugs
transport_init_session() and core_tmr_alloc_req() never return NULL,
they only return ERR_PTRs on error.
v2: Fix patch to return PTR_ERR(tl_nexus->se_sess) from Ankit Jain's
feedback.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Ankit Jain <jankit@suse.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/loopback/tcm_loop.c')
-rw-r--r-- | drivers/target/loopback/tcm_loop.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index dee2a2c909f5..d4fee2a9d66a 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -386,7 +386,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) | |||
386 | */ | 386 | */ |
387 | se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, (void *)tl_tmr, | 387 | se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, (void *)tl_tmr, |
388 | TMR_LUN_RESET); | 388 | TMR_LUN_RESET); |
389 | if (!se_cmd->se_tmr_req) | 389 | if (IS_ERR(se_cmd->se_tmr_req)) |
390 | goto release; | 390 | goto release; |
391 | /* | 391 | /* |
392 | * Locate the underlying TCM struct se_lun from sc->device->lun | 392 | * Locate the underlying TCM struct se_lun from sc->device->lun |
@@ -1017,6 +1017,7 @@ static int tcm_loop_make_nexus( | |||
1017 | struct se_portal_group *se_tpg; | 1017 | struct se_portal_group *se_tpg; |
1018 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; | 1018 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
1019 | struct tcm_loop_nexus *tl_nexus; | 1019 | struct tcm_loop_nexus *tl_nexus; |
1020 | int ret = -ENOMEM; | ||
1020 | 1021 | ||
1021 | if (tl_tpg->tl_hba->tl_nexus) { | 1022 | if (tl_tpg->tl_hba->tl_nexus) { |
1022 | printk(KERN_INFO "tl_tpg->tl_hba->tl_nexus already exists\n"); | 1023 | printk(KERN_INFO "tl_tpg->tl_hba->tl_nexus already exists\n"); |
@@ -1033,8 +1034,10 @@ static int tcm_loop_make_nexus( | |||
1033 | * Initialize the struct se_session pointer | 1034 | * Initialize the struct se_session pointer |
1034 | */ | 1035 | */ |
1035 | tl_nexus->se_sess = transport_init_session(); | 1036 | tl_nexus->se_sess = transport_init_session(); |
1036 | if (!tl_nexus->se_sess) | 1037 | if (IS_ERR(tl_nexus->se_sess)) { |
1038 | ret = PTR_ERR(tl_nexus->se_sess); | ||
1037 | goto out; | 1039 | goto out; |
1040 | } | ||
1038 | /* | 1041 | /* |
1039 | * Since we are running in 'demo mode' this call with generate a | 1042 | * Since we are running in 'demo mode' this call with generate a |
1040 | * struct se_node_acl for the tcm_loop struct se_portal_group with the SCSI | 1043 | * struct se_node_acl for the tcm_loop struct se_portal_group with the SCSI |
@@ -1060,7 +1063,7 @@ static int tcm_loop_make_nexus( | |||
1060 | 1063 | ||
1061 | out: | 1064 | out: |
1062 | kfree(tl_nexus); | 1065 | kfree(tl_nexus); |
1063 | return -ENOMEM; | 1066 | return ret; |
1064 | } | 1067 | } |
1065 | 1068 | ||
1066 | static int tcm_loop_drop_nexus( | 1069 | static int tcm_loop_drop_nexus( |