diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 9ab3fabea..88073848e 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4673,7 +4673,7 @@ static int scst_ws_push_single_write(struct scst_write_same_priv *wsp, if (sg == NULL) { PRINT_ERROR("Unable to alloc sg for %d blocks", blocks); res = -ENOMEM; - goto out_destroy; + goto out_free_cmd; } #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) @@ -4715,8 +4715,8 @@ out: TRACE_EXIT_RES(res); return res; -out_destroy: - scst_destroy_cmd(cmd); +out_free_cmd: + __scst_cmd_put(cmd); out_busy: scst_set_busy(ws_cmd); @@ -5328,6 +5328,26 @@ out_free: goto out; } +static void scst_destroy_cmd(struct scst_cmd *cmd) +{ + TRACE_ENTRY(); + + TRACE_DBG("Destroying cmd %p", cmd); + + scst_sess_put(cmd->sess); + + /* + * At this point tgt_dev can be dead, but the pointer remains non-NULL + */ + if (likely(cmd->tgt_dev != NULL)) + scst_put(cmd->cpu_cmd_counter); + + kmem_cache_free(scst_cmd_cachep, cmd); + + TRACE_EXIT(); + return; +} + /* No locks supposed to be held */ void scst_free_cmd(struct scst_cmd *cmd) { diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 47afeb739..68f9d3867 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -674,19 +674,6 @@ static inline void scst_sess_put(struct scst_session *sess) struct scst_cmd *scst_alloc_cmd(const uint8_t *cdb, unsigned int cdb_len, gfp_t gfp_mask); void scst_free_cmd(struct scst_cmd *cmd); -static inline void scst_destroy_cmd(struct scst_cmd *cmd) -{ - scst_sess_put(cmd->sess); - - /* - * At this point tgt_dev can be dead, but the pointer remains non-NULL - */ - if (likely(cmd->tgt_dev != NULL)) - scst_put(cmd->cpu_cmd_counter); - - kmem_cache_free(scst_cmd_cachep, cmd); - return; -} static inline void __scst_cmd_get(struct scst_cmd *cmd) {