aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2013-06-25 11:27:31 -0400
committerJames Bottomley <JBottomley@Parallels.com>2013-07-08 12:36:21 -0400
commit8c0eb596baa51f2b43949c698c644727ef17805c (patch)
treece5746cb1ac689451ee0f5c4b5c730bf8740a0a0 /drivers
parent6e97c9d5b85caaef9c2da7e410008df7e6d9d38a (diff)
[SCSI] qla2xxx: Fix a memory leak in an error path of qla2x00_process_els()
Avoid that the fcport structure gets leaked if bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN, the fcport allocation succeeds and the !vha->flags.online branch is taken. This was detected by Coverity. However, Coverity does not recognize that all qla2x00_process_els() callers specify either FC_BSG_RPT_ELS or FC_BSG_HST_ELS_NOLOGIN in the field bsg_job->request->msgcode and that the value of that field is not modified inside that function. This results in a false positive report about a possible memory leak in an error path for bsg_job->request->msgcode values other than the two mentioned values. Make it easy for Coverity (and for humans) to recognize that there is no fcport leak in the error path by changing the bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN test into bsg_job->request->msgcode != FC_BSG_RPT_ELS. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/qla2xxx/qla_bsg.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index b85f0021db3b..417eaad50ae2 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -269,6 +269,12 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
269 type = "FC_BSG_HST_ELS_NOLOGIN"; 269 type = "FC_BSG_HST_ELS_NOLOGIN";
270 } 270 }
271 271
272 if (!vha->flags.online) {
273 ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n");
274 rval = -EIO;
275 goto done;
276 }
277
272 /* pass through is supported only for ISP 4Gb or higher */ 278 /* pass through is supported only for ISP 4Gb or higher */
273 if (!IS_FWI2_CAPABLE(ha)) { 279 if (!IS_FWI2_CAPABLE(ha)) {
274 ql_dbg(ql_dbg_user, vha, 0x7001, 280 ql_dbg(ql_dbg_user, vha, 0x7001,
@@ -326,12 +332,6 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
326 NPH_FABRIC_CONTROLLER : NPH_F_PORT; 332 NPH_FABRIC_CONTROLLER : NPH_F_PORT;
327 } 333 }
328 334
329 if (!vha->flags.online) {
330 ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n");
331 rval = -EIO;
332 goto done;
333 }
334
335 req_sg_cnt = 335 req_sg_cnt =
336 dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list, 336 dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
337 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); 337 bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
@@ -399,7 +399,7 @@ done_unmap_sg:
399 goto done_free_fcport; 399 goto done_free_fcport;
400 400
401done_free_fcport: 401done_free_fcport:
402 if (bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN) 402 if (bsg_job->request->msgcode == FC_BSG_RPT_ELS)
403 kfree(fcport); 403 kfree(fcport);
404done: 404done:
405 return rval; 405 return rval;