From patchwork Wed Jun 17 11:21:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 6624111 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CB3E49F326 for ; Wed, 17 Jun 2015 11:22:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14B21208DD for ; Wed, 17 Jun 2015 11:22:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27213208D8 for ; Wed, 17 Jun 2015 11:22:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754900AbbFQLWQ (ORCPT ); Wed, 17 Jun 2015 07:22:16 -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 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NQ302C1968O2UE0@mailout3.samsung.com>; Wed, 17 Jun 2015 20:22:00 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.126]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 11.FA.28411.85851855; Wed, 17 Jun 2015 20:22:00 +0900 (KST) X-AuditID: cbfee68e-f79c56d000006efb-a7-55815858f06d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 43.22.25346.85851855; Wed, 17 Jun 2015 20:22:00 +0900 (KST) Received: from DO-MANINDER1-09.corp.samsungelectronics.net ([107.109.224.122]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NQ3002YI67K56A0@mmp2.samsung.com>; Wed, 17 Jun 2015 20:21:59 +0900 (KST) 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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Johannes Thumshirn --- 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);