All of lore.kernel.org
 help / color / mirror / Atom feed
From: Libo Chen <clbchenlibo.chen@huawei.com>
To: Tomas Henzl <thenzl@redhat.com>
Cc: megaraidlinux@lsi.com, JBottomley@parallels.com,
	linux-scsi@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	kashyap.desai@lsi.com, aradford@gmail.com,
	Li Zefan <lizefan@huawei.com>, Santosh Y <santoshsy@gmail.com>
Subject: Re: [PATCH RESEND] scsi: megaraid: check kzalloc
Date: Thu, 30 May 2013 10:32:59 +0800	[thread overview]
Message-ID: <51A6BA5B.4090008@huawei.com> (raw)
In-Reply-To: <51A6AD92.2030903@huawei.com>

On 2013/5/30 9:38, Libo Chen wrote:
> On 2013/5/29 23:03, Tomas Henzl wrote:
>> On 05/24/2013 11:40 AM, Libo Chen wrote:
>>> we should check kzalloc, avoid to hit oops
>>>
>>> Signed-off-by: Libo Chen <libo.chen@huawei.com>
>>> ---
>>>  drivers/scsi/megaraid.c |    4 ++++
>>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>>
>>> instead of checking scmd->device, sdev is more appropriate.
>>>
>>> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
>>> index 846f475..6b623cb 100644
>>> --- a/drivers/scsi/megaraid.c
>>> +++ b/drivers/scsi/megaraid.c
>>> @@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
>>>  	memset(scb, 0, sizeof(scb_t));
>>>
>>>  	sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
>>> +	if (sdev) {
>>> +		scsi_free_command(GFP_KERNEL, scmd);
>>
>> I think, that a mutex_unlock(&adapter->int_mtx); is also needed
>> Maybe just setting a rval = -ENOMEM and a jump to to some point below?
>>
>> tomash
> 
> thanks for catching this.
> 
> when kzalloc broken, fist unlock and then return.  I will update later.
> 

I think we can put kzalloc outside of mutex_lock(&adapter->int_mtx) ?
phase:

   mutex_lock	   kzalloc
   kzalloc     ->  mutex_lock
   	

> 
> Libo
> 
>>
>>> +		return -ENOMEM;
>>> +	}
>>>  	scmd->device = sdev;
>>>
>>>  	memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));
>>
>>
>> .
>>
> 



WARNING: multiple messages have this Message-ID (diff)
From: Libo Chen <clbchenlibo.chen@huawei.com>
To: Tomas Henzl <thenzl@redhat.com>
Cc: <megaraidlinux@lsi.com>, <JBottomley@parallels.com>,
	<linux-scsi@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	<kashyap.desai@lsi.com>, <aradford@gmail.com>,
	Li Zefan <lizefan@huawei.com>, Santosh Y <santoshsy@gmail.com>
Subject: Re: [PATCH RESEND] scsi: megaraid: check kzalloc
Date: Thu, 30 May 2013 10:32:59 +0800	[thread overview]
Message-ID: <51A6BA5B.4090008@huawei.com> (raw)
In-Reply-To: <51A6AD92.2030903@huawei.com>

On 2013/5/30 9:38, Libo Chen wrote:
> On 2013/5/29 23:03, Tomas Henzl wrote:
>> On 05/24/2013 11:40 AM, Libo Chen wrote:
>>> we should check kzalloc, avoid to hit oops
>>>
>>> Signed-off-by: Libo Chen <libo.chen@huawei.com>
>>> ---
>>>  drivers/scsi/megaraid.c |    4 ++++
>>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>>
>>> instead of checking scmd->device, sdev is more appropriate.
>>>
>>> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
>>> index 846f475..6b623cb 100644
>>> --- a/drivers/scsi/megaraid.c
>>> +++ b/drivers/scsi/megaraid.c
>>> @@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
>>>  	memset(scb, 0, sizeof(scb_t));
>>>
>>>  	sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
>>> +	if (sdev) {
>>> +		scsi_free_command(GFP_KERNEL, scmd);
>>
>> I think, that a mutex_unlock(&adapter->int_mtx); is also needed
>> Maybe just setting a rval = -ENOMEM and a jump to to some point below?
>>
>> tomash
> 
> thanks for catching this.
> 
> when kzalloc broken, fist unlock and then return.  I will update later.
> 

I think we can put kzalloc outside of mutex_lock(&adapter->int_mtx) ?
phase:

   mutex_lock	   kzalloc
   kzalloc     ->  mutex_lock
   	

> 
> Libo
> 
>>
>>> +		return -ENOMEM;
>>> +	}
>>>  	scmd->device = sdev;
>>>
>>>  	memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));
>>
>>
>> .
>>
> 



  reply	other threads:[~2013-05-30  2:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-24  2:22 [PATCH] scsi: megaraid: check kzalloc Libo Chen
2013-05-24  2:22 ` Libo Chen
2013-05-24  3:20 ` Santosh Y
2013-05-24  9:30   ` Libo Chen
2013-05-24  9:30     ` Libo Chen
2013-05-24  9:40 ` [PATCH RESEND] " Libo Chen
2013-05-24  9:40   ` Libo Chen
2013-05-29 15:03   ` Tomas Henzl
2013-05-30  1:38     ` Libo Chen
2013-05-30  1:38       ` Libo Chen
2013-05-30  2:32       ` Libo Chen [this message]
2013-05-30  2:32         ` Libo Chen
2013-05-30 10:54         ` Tomas Henzl
2013-05-29 15:12   ` Tomas Henzl
2013-06-04  9:33   ` [PATCH v2] " Libo Chen
2013-06-04  9:33     ` Libo Chen
2013-06-04 12:14     ` Tomas Henzl
2013-06-05  1:27       ` Libo Chen
2013-06-05  1:27         ` Libo Chen

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=51A6BA5B.4090008@huawei.com \
    --to=clbchenlibo.chen@huawei.com \
    --cc=JBottomley@parallels.com \
    --cc=aradford@gmail.com \
    --cc=kashyap.desai@lsi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=megaraidlinux@lsi.com \
    --cc=santoshsy@gmail.com \
    --cc=thenzl@redhat.com \
    /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: link
Be 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.