From df55eeb5dac00079529a894890d1171e8935dd00 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 20 Dec 2016 05:55:19 +0000 Subject: [PATCH] Minor misc changes git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7068 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/iscsi.c | 8 ++++++++ scst/include/backport.h | 4 +++- scst/src/dev_handlers/scst_user.c | 8 ++++++++ scst/src/dev_handlers/scst_vdisk.c | 3 +++ scst/src/scst_lib.c | 1 - scst/src/scst_main.c | 1 + 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 53100ca00..fa0908b42 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -459,6 +459,14 @@ void cmnd_done(struct iscsi_cmnd *cmnd) /* Order between above and below code is important! */ if ((cmnd->scst_cmd != NULL) || (cmnd->scst_aen != NULL)) { + /* + * Tell Coverity when cmnd->scst_cmd or scst_aen is set. + */ + if (cmnd->scst_state == ISCSI_CMD_STATE_AEN) + EXTRACHECKS_BUG_ON(!cmnd->scst_aen); + else + EXTRACHECKS_BUG_ON(!cmnd->scst_cmd); + switch (cmnd->scst_state) { case ISCSI_CMD_STATE_PROCESSED: TRACE_DBG("cmd %p PROCESSED", cmnd); diff --git a/scst/include/backport.h b/scst/include/backport.h index 93e1b004a..ea40cea6d 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -335,13 +335,15 @@ enum umh_wait { LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 41)) && \ ! (LINUX_VERSION_CODE >> 8 == KERNEL_VERSION(3, 2, 0) >> 8 && \ LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 44)) && \ - !defined(CONFIG_SUSE_KERNEL) && \ + (!defined(CONFIG_SUSE_KERNEL) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 101)) && \ (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 6 || \ (RHEL_MAJOR -0 == 6 && RHEL_MINOR -0 < 6)) /* * See also commit 4b20db3 (kref: Implement kref_get_unless_zero v3 -- v3.8). * See also commit e3a5505 in branch stable/linux-3.4.y (v3.4.41). * See also commit 3fa8ee5 in branch stable/linux-3.2.y (v3.2.44). + * See also commit 6b9508d in the SuSE kernel tree. */ static inline int __must_check kref_get_unless_zero(struct kref *kref) { diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index aad69ee01..055ef1449 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -1828,6 +1828,14 @@ static int dev_user_process_reply_exec(struct scst_user_cmd *ucmd, scst_set_resp_data_len(cmd, ereply->resp_data_len); } +#ifdef CONFIG_SCST_EXTRACHECKS + if (unlikely((ereply->resp_data_len == 0) && (ereply->pbuf != 0))) { + PRINT_WARNING("Supplied pbuf 0x%llx ignored, because " + "resp_data_len is 0. Memory leak? (op %s)", + (unsigned long long)ereply->pbuf, scst_get_opcode_name(cmd)); + } +#endif + cmd->status = ereply->status; if (ereply->sense_len != 0) { int sense_len, rc; diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 50da21958..22bc8ac75 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3429,7 +3429,9 @@ enomem: TRACE_EXIT_RES(-ENOMEM); return scst_get_cmd_abnormal_done_state(cmd); } + #else + static int fileio_alloc_data_buf(struct scst_cmd *cmd) { struct vdisk_cmd_params *p; @@ -3447,6 +3449,7 @@ static int fileio_alloc_data_buf(struct scst_cmd *cmd) static void finish_read(struct scatterlist *sg, int sg_cnt) { } + #endif static int vdev_do_job(struct scst_cmd *cmd, const vdisk_op_fn *ops) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 4945f2b0e..ac83cac21 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6709,7 +6709,6 @@ out_done: goto out; } - int scst_finish_internal_cmd(struct scst_cmd *cmd) { int res; diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 8c569d274..7db8f14dc 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -2835,6 +2835,7 @@ static void __exit exit_scst(void) scst_deinit_threads(&scst_main_cmd_threads); scsi_unregister_interface(&scst_interface); + #ifdef CONFIG_SCST_PROC scst_del_free_acg(scst_default_acg, false); #endif