[openib-general] [PATCH][kdapl] Small changes in dapl_hca_all oc/dapl_hca_free functions
James Lentini
jlentini at netapp.com
Wed Jun 22 10:22:35 PDT 2005
On Mon, 20 Jun 2005, Tom Duffy wrote:
> On Mon, 2005-06-20 at 20:00 +0300, Itamar Rabenstein wrote:
>> Hi Tom,
>> I was just copied to original code from dapl_os_strdup() to
>> dapl_hca_alloc().
>> so if it is a problem is it was there in the code before my patch.
>> But why do you think we need strncpy and not strcpy ?
>> name param is null terminated string.
>
> It is generally not a good idea to allow an arbitrary sized string in
> the kernel. Especially when you are kmalloc()ing the size.
If we ignore the mechanism by which this string is copied for a
moment, it turns out the hca structure's name field isn't even
necessary. It is only used once, in dapl_add_port().
The code looks roughly like this:
hca = dapl_hca_alloc(provider_info.ia_name, device, port);
status = dapl_ib_open_hca(hca->name, hca);
The code allocs an HCA, initializing the hca->name field to
provider_info.ia_name and then makes use of this field for the one and
only time immediately afterwards.
I'll remove the HCA's name field and use provider_info.ia_name in the
call to dapl_ib_open_hca() instead.
In the future, if there is some reason the HCA structure should
contain this information, it should have a pointer to the dat_provider
structure which contains the IA name. That will eliminate duplicating
this information.
james
More information about the general
mailing list