Found with coccicheck. The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci.
Unified · Split
| @@ -1267,12 +1267,12 @@ int omap_gem_set_sync_object(struct drm_gem_object *obj, void *syncobj) · 1266 unmodified lines | ||
| 1267 | 1267 | |
| 1268 | 1268 | if ((omap_obj->flags & OMAP_BO_EXT_SYNC) && !syncobj) { |
| 1269 | 1269 | /* clearing a previously set syncobj */ |
| 1270 | − syncobj = kzalloc(sizeof(*omap_obj->sync), GFP_ATOMIC); | |
| 1270 | + syncobj = kmemdup(omap_obj->sync, sizeof(*omap_obj->sync), | |
| 1271 | + GFP_ATOMIC); | |
| 1271 | 1272 | if (!syncobj) { |
| 1272 | 1273 | ret = -ENOMEM; |
| 1273 | 1274 | goto unlock; |
| 1274 | 1275 | } |
| 1275 | − memcpy(syncobj, omap_obj->sync, sizeof(*omap_obj->sync)); | |
| 1276 | 1276 | omap_obj->flags &= ~OMAP_BO_EXT_SYNC; |
| 1277 | 1277 | omap_obj->sync = syncobj; |
| 1278 | 1278 | } else if (syncobj && !(omap_obj->flags & OMAP_BO_EXT_SYNC)) { |