staging/omapdrm: Use kmemdup rather than duplicating its implementation
authorPeter Huewe <peterhuewe@gmx.de>
Fri, 25 Jan 2013 23:40:13 +0000 (00:40 +0100)
committerRob Clark <robdclark@gmail.com>
Sat, 16 Feb 2013 22:38:05 +0000 (17:38 -0500)
Found with coccicheck.
The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Rob Clark <rob@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/omapdrm/omap_gem.c

index 08f1e292ed201c57a65bddf67e84de6695a5bf0a..f9297eb2599eb0525f0f456bf39d58dff90c11f8 100644 (file)
@@ -1267,12 +1267,12 @@ int omap_gem_set_sync_object(struct drm_gem_object *obj, void *syncobj)
 
        if ((omap_obj->flags & OMAP_BO_EXT_SYNC) && !syncobj) {
                /* clearing a previously set syncobj */
-               syncobj = kzalloc(sizeof(*omap_obj->sync), GFP_ATOMIC);
+               syncobj = kmemdup(omap_obj->sync, sizeof(*omap_obj->sync),
+                                 GFP_ATOMIC);
                if (!syncobj) {
                        ret = -ENOMEM;
                        goto unlock;
                }
-               memcpy(syncobj, omap_obj->sync, sizeof(*omap_obj->sync));
                omap_obj->flags &= ~OMAP_BO_EXT_SYNC;
                omap_obj->sync = syncobj;
        } else if (syncobj && !(omap_obj->flags & OMAP_BO_EXT_SYNC)) {