[openib-general] [PATCH][kdapl] Small changes in dapl_hca_alloc/dapl_hca_free functions

Tom Duffy tomduffy at gmail.com
Mon Jun 20 08:00:13 PDT 2005


On 6/20/05, Itamar Rabenstein <itamar at mellanox.co.il> wrote:
> Small changes in dapl_hca_alloc/dapl_hca_free function
> 
> Signed-off-by: Itamar Rabenstein <itamar at mellanox.co.il>
> 
> diff -Nurp -X dontdiff dat-provider_hash/dapl_hca_util.c dat-provider/dapl_hca_util.c
> --- dat-provider_hash/dapl_hca_util.c   Sun Jun 19 16:12:55 2005
> +++ dat-provider/dapl_hca_util.c        Sun Jun 19 16:30:07 2005
> @@ -54,23 +54,18 @@
>  struct dapl_hca *dapl_hca_alloc(char *name, struct ib_device *device, u8 port)
>  {
>         struct dapl_hca *hca;
> -
> -       hca = kmalloc(sizeof *hca, GFP_ATOMIC);
> +       int malloc_size = sizeof *hca + strlen(name) + 1;
> +
> +       hca = kmalloc(malloc_size, GFP_ATOMIC);
>         if (hca) {
> -               memset(hca, 0, sizeof *hca);
> -
> +               memset(hca, 0, malloc_size);
>                 spin_lock_init(&hca->lock);
>                 INIT_LIST_HEAD(&hca->ia_list);
> -
> -               hca->name = dapl_os_strdup(name);
> +               hca->name = (char *)hca + sizeof *hca;
> +               strcpy(hca->name, name);

Shouldn't you use strncpy() and bound it?

-tduffy



More information about the general mailing list