From 485c9c7f29b30824b5c215772b302050507f53fb Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 3 Mar 2009 18:17:36 +0000 Subject: [PATCH] Fixes possible crash on BUG_ON (or memory leak without it), if REQUEST SENSE was issued on a command, in which empty sense was returned. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@686 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 1cc0192a3..0d8d37979 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -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;