Fixes possible crash on BUG_ON (or memory leak without it), if REQUEST SENSE was...
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 3 Mar 2009 18:17:36 +0000 (18:17 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 3 Mar 2009 18:17:36 +0000 (18:17 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@686 d57e44dd-8a1f-0410-8b47-8ef2f437770f

scst/src/scst_lib.c

index 1cc0192..0d8d379 100644 (file)
@@ -1069,6 +1069,13 @@ int scst_prepare_request_sense(struct scst_cmd *orig_cmd)
 
        TRACE_ENTRY();
 
+       if (orig_cmd->sense != NULL) {
+               TRACE_MEM("Releasing sense %p (orig_cmd %p)",
+                       orig_cmd->sense, orig_cmd);
+               mempool_free(orig_cmd->sense, scst_sense_mempool);
+               orig_cmd->sense = NULL;
+       }
+
        rs_cmd = scst_create_prepare_internal_cmd(orig_cmd, sbuf_size);
        if (rs_cmd == NULL)
                goto out_error;