On Tue, 2017-07-11 at 23:04 +0300, Dan Carpenter wrote: > This is a semi-automatic email about new static checker warnings. > > The patch 75f141aaf48e: "target/tcm_loop: Use target_submit_tmr() > instead of open-coding this function" from May 23, 2017, leads to the > following Smatch complaint: > > drivers/target/loopback/tcm_loop.c:247 tcm_loop_issue_tmr() > warn: variable dereferenced before check 'se_cmd' (see line 234) > > drivers/target/loopback/tcm_loop.c > 223 tl_cmd = kmem_cache_zalloc(tcm_loop_cmd_cache, GFP_KERNEL); > 224 if (!tl_cmd) { > 225 pr_err("Unable to allocate memory for tl_cmd\n"); > 226 return ret; > 227 } > 228 > 229 init_completion(&tl_cmd->tmr_done); > 230 > 231 se_cmd = &tl_cmd->tl_se_cmd; > 232 se_sess = tl_tpg->tl_nexus->se_sess; > 233 > 234 rc = target_submit_tmr(se_cmd, se_sess, tl_cmd->tl_sense_buf, lun, > ^^^^^^ > Dereferenced here. > > 235 NULL, tmr, GFP_KERNEL, task, > 236 TARGET_SCF_ACK_KREF); > 237 if (rc < 0) > 238 goto release; > 239 wait_for_completion(&tl_cmd->tmr_done); > 240 ret = se_cmd->se_tmr_req->response; > 241 target_put_sess_cmd(se_cmd); > 242 > 243 out: > 244 return ret; > 245 > 246 release: > 247 if (se_cmd) > 248 transport_generic_free_cmd(se_cmd, 0); > 249 else > 250 kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > This is dead code. > > 251 goto out; > 252 } Hello Dan, Although I agree that the code marked as dead code is indeed dead code, I think that this code became dead code due to another patch, namely commit 4d3895d5ea43 ("target/tcm_loop: Merge struct tcm_loop_cmd and struct tcm_loop_tmr"). Anyway, thanks for the report. Removing the dead code would be good but since this warning does not indicate a bug removing the dead code is not urgent. Bart.-- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html