Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754987AbbFQLWU (ORCPT ); Wed, 17 Jun 2015 07:22:20 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:39648 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754756AbbFQLWC (ORCPT ); Wed, 17 Jun 2015 07:22:02 -0400 X-AuditID: cbfee68e-f79c56d000006efb-a7-55815858f06d From: Maninder Singh To: JBottomley@odin.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pankaj.m@samsung.com, Maninder Singh Subject: [PATCH 1/1] scsi: Initialize sdp after NULL check of cmnd Date: Wed, 17 Jun 2015 16:51:07 +0530 Message-id: <1434540067-69384-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 2.1.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDLMWRmVeSWpSXmKPExsWyRsSkTjciojHU4MhJHYv/62+zWFzeNYfN ovv6DjaLw/PbWCzuvdnK5MDqcfjHD2aPvi2rGD0+b5ILYI7isklJzcksSy3St0vgynj15CNz wTWuipNHPjE1MD7j6GLk4JAQMJFofR7TxcgJZIpJXLi3nq2LkYtDSGApo0TnyrOMEAkTiUNT rrKA2EIC0xklvt3ggCiaxCTxZNE0ZpAEm4CexKpde1hAhooIBEssnxsOYjILOElM/6oHUiEM ZN76uRVsDIuAqkRDw31WEJtXwF3ie8MEdohVchLnj/9kBhkvIXCfTWL+wUtMEA0CEt8mH2KB uFlWYtMBZoh6SYmDK26wTGAUXMDIsIpRNLUguaA4Kb3ISK84Mbe4NC9dLzk/dxMjMBBP/3vW t4Px5gHrQ4wCHIxKPLwPwhtDhVgTy4orcw8xmgJtmMgsJZqcDwz3vJJ4Q2MzIwtTE1NjI3NL MyVx3gSpn8FCAumJJanZqakFqUXxRaU5qcWHGJk4OKUaGDeYVJnxy/NnbfyevknZOEF9PUvU xHDDlGXiv0V/Z8v2zTm8YvbuGxMni/7TU/r9e/pztQuL618pRKoI7PXMZZvkemfC911KN5OX qH3teFn3/9H9Ta927/z5ZOu99HWNSxd5bi8sW2FnePuk7BvnW80v777e2NXsumD1PclbO2o+ 7a0XKjisZBigxFKckWioxVxUnAgAPhaFQj8CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRmVeSWpSXmKPExsVy+t9jQd2IiMZQgwNrlSz+r7/NYnF51xw2 i+7rO9gsDs9vY7G492YrkwOrx+EfP5g9+rasYvT4vEkugDmqgdEmIzUxJbVIITUvOT8lMy/d Vsk7ON453tTMwFDX0NLCXEkhLzE31VbJxSdA1y0zB2inkkJZYk4pUCggsbhYSd8O04TQEDdd C5jGCF3fkCC4HiMDNJCwhjHj1ZOPzAXXuCpOHvnE1MD4jKOLkZNDQsBE4tCUqywQtpjEhXvr 2UBsIYHpjBLfbgDVcAHZk5gkniyaxgySYBPQk1i1aw9QAweHiECwxPK54SAms4CTxPSveiAV wkDmrZ9bwUayCKhKNDTcZwWxeQXcJb43TGCHWCUncf74T+YJjNwLGBlWMYqmFiQXFCel5xrq FSfmFpfmpesl5+duYgQH+jOpHYwrGywOMQpwMCrx8O72bQwVYk0sK67MPcQowcGsJMK7yR0o xJuSWFmVWpQfX1Sak1p8iNEUaPtEZinR5HxgFOaVxBsam5ibGptamliYmFkqifOezPcJFRJI TyxJzU5NLUgtgulj4uCUamBsXzhLqf5qvliFxUHOyHurMvRXHjUQUNu6LlB3Zd3l07Inb6xt MFpdKOvHUGE6xeaP7feK5R6mmYuubH+cvSzwHpPRom9vXR1WybhNWsLifWbqHa3MZQ9q/Q3Y Z4SWGBpYHM1lnlIso6ZYbnvh2rM/Mz7sShbOSmEL7o/IUv1WOYlfJu/gr3VKLMUZiYZazEXF iQCpvcaTigIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1572 Lines: 44 Currently cmnd pointer is already dereferenced before NULL check and thus getting below warning in static analysis: warn: variable dereferenced before check 'cmnd' So initialize struct scsi_device *sdp after NULL check of cmnd Signed-off-by: Maninder Singh Reviewed-by: Akhilesh Kumar --- drivers/scsi/scsi_debug.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 1f8e2dc..bb97a5a 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -3942,7 +3942,7 @@ schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip, unsigned long iflags; int k, num_in_q, qdepth, inject; struct sdebug_queued_cmd *sqcp = NULL; - struct scsi_device *sdp = cmnd->device; + struct scsi_device *sdp; if (NULL == cmnd || NULL == devip) { pr_warn("%s: called with NULL cmnd or devip pointer\n", @@ -3950,6 +3950,8 @@ schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip, /* no particularly good error to report back */ return SCSI_MLQUEUE_HOST_BUSY; } + + sdp = cmnd->device; if ((scsi_result) && (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)) sdev_printk(KERN_INFO, sdp, "%s: non-zero result=0x%x\n", __func__, scsi_result); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/