Hush Coverity warning of scst_ws_push_single_write() uninitialized pointer

Coverity warns that sgv may be used uninitialized. The warning
applies to WRITE SAME commands with LBDATA == PBDATA == 0 (replicate
a single block of user data into the specified LBA range).

The warning appears to be spurious - when LBDATA == PBDATA == 0,
scst_ws_write_cmd_finished() will not use the uninitialized value
saved by scst_ws_push_single_write().

Move initialization of sgv earlier in the function to quiesce the warning.

Signed-off-by: Steven J. Magnani <steve@digidescorp.com>


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5266 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2014-02-06 13:30:06 +00:00
parent cf699a6d95
commit 022a8a6847

View File

@@ -4645,7 +4645,7 @@ static int scst_ws_push_single_write(struct scst_write_same_priv *wsp,
uint8_t write16_cdb[16];
struct scatterlist *sg;
int sg_cnt, len = blocks << ws_cmd->dev->block_shift;
struct sgv_pool_obj *sgv;
struct sgv_pool_obj *sgv = NULL;
struct scst_cmd *cmd;
int64_t cur_lba;
@@ -4686,7 +4686,6 @@ static int scst_ws_push_single_write(struct scst_write_same_priv *wsp,
goto set_add;
}
sgv = NULL; /* we don't supply sgv */
sg = sgv_pool_alloc(ws_cmd->tgt_dev->pool, len, GFP_KERNEL, 0,
&sg_cnt, &sgv, &cmd->dev->dev_mem_lim, NULL);
if (sg == NULL) {