lkml.org 
[lkml]   [2014]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 3/18] VMCI: Use kmemdup instead of kmalloc + memcpy


    Am 26.05.2014 17:21, schrieb Benoit Taine:
    > This issue was reported by coccicheck using the semantic patch
    > at scripts/coccinelle/api/memdup.cocci
    >
    > Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
    > ---
    > Tested by compilation without errors.
    >
    > drivers/misc/vmw_vmci/vmci_datagram.c | 3 +--
    > 1 file changed, 1 insertion(+), 2 deletions(-)
    >
    > diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c
    > index f3cdd90..d93b469 100644
    > --- a/drivers/misc/vmw_vmci/vmci_datagram.c
    > +++ b/drivers/misc/vmw_vmci/vmci_datagram.c
    > @@ -276,11 +276,10 @@ static int dg_dispatch_as_host(u32 context_id, struct vmci_datagram *dg)
    > }
    >
    > /* We make a copy to enqueue. */
    > - new_dg = kmalloc(dg_size, GFP_KERNEL);
    > + new_dg = kmemdup(dg, dg_size, GFP_KERNEL);
    > if (new_dg == NULL)
    > return VMCI_ERROR_NO_MEM;


    i can not see much of the code but this looks like
    new_dg=dg;
    what is possible in c99.

    re,
    wh

    >
    > - memcpy(new_dg, dg, dg_size);
    > retval = vmci_ctx_enqueue_datagram(dg->dst.context, new_dg);
    > if (retval < VMCI_SUCCESS) {
    > kfree(new_dg);
    >
    > --
    > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
    > the body of a message to majordomo@vger.kernel.org
    > More majordomo info at http://vger.kernel.org/majordomo-info.html
    >


    \
     
     \ /
      Last update: 2014-05-26 18:41    [W:4.622 / U:0.252 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site