RE: [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition

2017-12-26 Thread Raghava Aditya Renukunta


> -Original Message-
> From: Bart Van Assche [mailto:bart.vanass...@wdc.com]
> Sent: Thursday, December 21, 2017 9:54 AM
> To: j...@linux.vnet.ibm.com; Raghava Aditya Renukunta
> <raghavaaditya.renuku...@microsemi.com>; linux-scsi@vger.kernel.org;
> martin.peter...@oracle.com
> Cc: dl-esc-Aacraid Linux Driver <aacr...@microsemi.com>;
> gpicc...@linux.vnet.ibm.com; Tom White <tom.wh...@microsemi.com>;
> Scott Benesh <scott.ben...@microsemi.com>
> Subject: Re: [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition
> 
> EXTERNAL EMAIL
> 
> 
> On Thu, 2017-12-21 at 09:33 -0800, Raghava Aditya Renukunta wrote:
> > + char *cp;
> > + char *cname = kmalloc(sizeof(sup_adap_info-
> >adapter_type_text),
> > + GFP_ATOMIC);
> 
> Why did you choose to use GFP_ATOMIC instead of GFP_KERNEL in the
> above
> kmalloc() call?

It was mainly because of a trace call that cut thru the kmalloc call. 
 
> > +
> > + if (!cname)
> > + return;
> > +
> > + cp = cname;
> > + memcpy(cname, sup_adap_info->adapter_type_text,
> > + sizeof(sup_adap_info->adapter_type_text));
> 
> Is the sup_adap_info->adapter_type_text a string that is \0-terminated? If
> so,
> have you considered to use kmemdup() instead of kmalloc() + memcpy()?

I will take that into consideration Bart.

Thank you 
Raghava Aditya

> Thanks,
> 
> Bart.


Re: [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition

2017-12-21 Thread Bart Van Assche
On Thu, 2017-12-21 at 09:33 -0800, Raghava Aditya Renukunta wrote:
> + char *cp;
> + char *cname = kmalloc(sizeof(sup_adap_info->adapter_type_text),
> + GFP_ATOMIC);

Why did you choose to use GFP_ATOMIC instead of GFP_KERNEL in the above
kmalloc() call?

> +
> + if (!cname)
> + return;
> +
> + cp = cname;
> + memcpy(cname, sup_adap_info->adapter_type_text,
> + sizeof(sup_adap_info->adapter_type_text));

Is the sup_adap_info->adapter_type_text a string that is \0-terminated? If so,
have you considered to use kmemdup() instead of kmalloc() + memcpy()?

Thanks,

Bart.