return NULL;
 
        state = kzalloc(sizeof(*state), GFP_KERNEL);
+       if (!state)
+               return NULL;
 
        __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
 
        struct amdgpu_i2c_adapter *i2c;
 
        i2c = kzalloc(sizeof(struct amdgpu_i2c_adapter), GFP_KERNEL);
+       if (!i2c)
+               return NULL;
        i2c->base.owner = THIS_MODULE;
        i2c->base.class = I2C_CLASS_DDC;
        i2c->base.dev.parent = &adev->pdev->dev;
        DRM_DEBUG_DRIVER("%s()\n", __func__);
 
        i2c = create_i2c(link->ddc, link->link_index, &res);
+       if (!i2c) {
+               DRM_ERROR("Failed to create i2c adapter data\n");
+               return -ENOMEM;
+       }
+
        aconnector->i2c = i2c;
        res = i2c_add_adapter(&i2c->base);