lkml.org 
[lkml]   [2013]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] scsi: megaraid: check kzalloc
On 2013/5/24 11:20, Santosh Y wrote:
> On Fri, May 24, 2013 at 7:52 AM, Libo Chen <clbchenlibo.chen@huawei.com> 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(-)
>>
>> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
>> index 846f475..195b095 100644
>> --- a/drivers/scsi/megaraid.c
>> +++ b/drivers/scsi/megaraid.c
>> @@ -4162,6 +4162,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
>>
>> sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
>> scmd->device = sdev;
> ^^^^^^
> I guess assigning after the NULL check of 'sdev' is more appropriate.

Ah, there is a little different. ok, I will update.


Thanks,

Libo

>
>> + if (!scmd->device) {
>> + scsi_free_command(GFP_KERNEL, scmd);
>> + return -ENOMEM;
>> + }
>>
>> memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));
>> scmd->cmnd = adapter->int_cdb;
>> --
>> 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
>
>
>




\
 
 \ /
  Last update: 2013-05-24 12:21    [W:0.149 / U:0.432 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site