Some fields that we're going to add cannot be just copied over to the new state, and thus kmemdup is a bit unnecessary. Let's move to kzalloc instead, and clean it up in the process. Signed-off-by: Maxime Ripard <maxime@xxxxxxxxxx> --- drivers/gpu/drm/vc4/vc4_kms.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c index d6712924681e..3d0065df10f9 100644 --- a/drivers/gpu/drm/vc4/vc4_kms.c +++ b/drivers/gpu/drm/vc4/vc4_kms.c @@ -695,23 +695,25 @@ static int vc4_load_tracker_obj_init(struct vc4_dev *vc4) static struct drm_private_state * vc4_hvs_channels_duplicate_state(struct drm_private_obj *obj) { + struct vc4_hvs_state *old_state = to_vc4_hvs_state(obj->state); struct vc4_hvs_state *state; - state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL); + state = kzalloc(sizeof(*state), GFP_KERNEL); if (!state) return NULL; __drm_atomic_helper_private_obj_duplicate_state(obj, &state->base); + state->unassigned_channels = old_state->unassigned_channels; + return &state->base; } static void vc4_hvs_channels_destroy_state(struct drm_private_obj *obj, struct drm_private_state *state) { - struct vc4_hvs_state *hvs_state; + struct vc4_hvs_state *hvs_state = to_vc4_hvs_state(state); - hvs_state = to_vc4_hvs_state(state); kfree(hvs_state); } -- 2.28.0 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel