lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51A72FFE.9070602@redhat.com>
Date:	Thu, 30 May 2013 12:54:54 +0200
From:	Tomas Henzl <thenzl@...hat.com>
To:	Libo Chen <clbchenlibo.chen@...wei.com>
CC:	megaraidlinux@....com, JBottomley@...allels.com,
	linux-scsi@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
	kashyap.desai@....com, aradford@...il.com,
	Li Zefan <lizefan@...wei.com>, Santosh Y <santoshsy@...il.com>
Subject: Re: [PATCH RESEND] scsi: megaraid: check kzalloc

On 05/30/2013 04:32 AM, Libo Chen wrote:
> 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@...wei.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:

Yes, that is also possible, depends on what you prefer.

>
>    mutex_lock	   kzalloc
>    kzalloc     ->  mutex_lock
>    	
>
>> Libo
>>
>>>> +		return -ENOMEM;
>>>> +	}
>>>>  	scmd->device = sdev;
>>>>
>>>>  	memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));
>>>
>>> .
>>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ