Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755159AbbFQLif (ORCPT ); Wed, 17 Jun 2015 07:38:35 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49571 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753314AbbFQLiW (ORCPT ); Wed, 17 Jun 2015 07:38:22 -0400 Date: Wed, 17 Jun 2015 13:38:19 +0200 From: Johannes Thumshirn To: Maninder Singh Cc: JBottomley@odin.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, pankaj.m@samsung.com Subject: Re: [PATCH 1/1] scsi: Initialize sdp after NULL check of cmnd Message-ID: <20150617113819.GC22164@c203.arch.suse.de> References: <1434540067-69384-1-git-send-email-maninder1.s@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1434540067-69384-1-git-send-email-maninder1.s@samsung.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2241 Lines: 58 On Wed, Jun 17, 2015 at 04:51:07PM +0530, Maninder Singh wrote: > 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-scsi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Johannes Thumshirn -- Johannes Thumshirn Storage jthumshirn@suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N?rnberg) -- 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/