From: Dan Carpenter <error27@gmail.com> To: "James E.J. Bottomley" <James.Bottomley@suse.de> Cc: Jiri Slaby <jslaby@suse.cz>, Srinivas <satyasrinivasp@hcl.in>, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch 2/2] mvsas: dereferencing before checking Date: Wed, 11 Aug 2010 09:41:57 +0200 [thread overview] Message-ID: <20100811074157.GB30429@bicker> (raw) If "mvi_dev" is NULL then we have to test it at the start of the function and return if it is null. In the original code, we dereferenced "mvi_dev" before the check to assign "mvi" and then we dereferenced "mvi" to take the spin lock. Signed-off-by: Dan Carpenter <error27@gmail.com> diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c index 406246c..a5c5aa5 100644 --- a/drivers/scsi/mvsas/mv_sas.c +++ b/drivers/scsi/mvsas/mv_sas.c @@ -1379,19 +1379,21 @@ void mvs_dev_gone_notify(struct domain_device *dev) { unsigned long flags = 0; struct mvs_device *mvi_dev = dev->lldd_dev; - struct mvs_info *mvi = mvi_dev->mvi_info; - - spin_lock_irqsave(&mvi->lock, flags); + struct mvs_info *mvi; - if (mvi_dev) { - mv_dprintk("found dev[%d:%x] is gone.\n", - mvi_dev->device_id, mvi_dev->dev_type); - mvs_release_task(mvi, dev); - mvs_free_reg_set(mvi, mvi_dev); - mvs_free_dev(mvi_dev); - } else { + if (!mvi_dev) { mv_dprintk("found dev has gone.\n"); + return; } + + mvi = mvi_dev->mvi_info; + spin_lock_irqsave(&mvi->lock, flags); + + mv_dprintk("found dev[%d:%x] is gone.\n", + mvi_dev->device_id, mvi_dev->dev_type); + mvs_release_task(mvi, dev); + mvs_free_reg_set(mvi, mvi_dev); + mvs_free_dev(mvi_dev); dev->lldd_dev = NULL; spin_unlock_irqrestore(&mvi->lock, flags);
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com> To: "James E.J. Bottomley" <James.Bottomley@suse.de> Cc: Jiri Slaby <jslaby@suse.cz>, Srinivas <satyasrinivasp@hcl.in>, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch 2/2] mvsas: dereferencing before checking Date: Wed, 11 Aug 2010 07:41:57 +0000 [thread overview] Message-ID: <20100811074157.GB30429@bicker> (raw) If "mvi_dev" is NULL then we have to test it at the start of the function and return if it is null. In the original code, we dereferenced "mvi_dev" before the check to assign "mvi" and then we dereferenced "mvi" to take the spin lock. Signed-off-by: Dan Carpenter <error27@gmail.com> diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c index 406246c..a5c5aa5 100644 --- a/drivers/scsi/mvsas/mv_sas.c +++ b/drivers/scsi/mvsas/mv_sas.c @@ -1379,19 +1379,21 @@ void mvs_dev_gone_notify(struct domain_device *dev) { unsigned long flags = 0; struct mvs_device *mvi_dev = dev->lldd_dev; - struct mvs_info *mvi = mvi_dev->mvi_info; - - spin_lock_irqsave(&mvi->lock, flags); + struct mvs_info *mvi; - if (mvi_dev) { - mv_dprintk("found dev[%d:%x] is gone.\n", - mvi_dev->device_id, mvi_dev->dev_type); - mvs_release_task(mvi, dev); - mvs_free_reg_set(mvi, mvi_dev); - mvs_free_dev(mvi_dev); - } else { + if (!mvi_dev) { mv_dprintk("found dev has gone.\n"); + return; } + + mvi = mvi_dev->mvi_info; + spin_lock_irqsave(&mvi->lock, flags); + + mv_dprintk("found dev[%d:%x] is gone.\n", + mvi_dev->device_id, mvi_dev->dev_type); + mvs_release_task(mvi, dev); + mvs_free_reg_set(mvi, mvi_dev); + mvs_free_dev(mvi_dev); dev->lldd_dev = NULL; spin_unlock_irqrestore(&mvi->lock, flags);
next reply other threads:[~2010-08-11 7:43 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-08-11 7:41 Dan Carpenter [this message] 2010-08-11 7:41 ` [patch 2/2] mvsas: dereferencing before checking Dan Carpenter
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20100811074157.GB30429@bicker \ --to=error27@gmail.com \ --cc=James.Bottomley@suse.de \ --cc=jslaby@suse.cz \ --cc=kernel-janitors@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-scsi@vger.kernel.org \ --cc=satyasrinivasp@hcl.in \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.