int offset;
dev_priv->bios.data = kzalloc(NV50_PROM__ESIZE, GFP_KERNEL);
+ if (!dev_priv->bios.data)
+ return -ENOMEM;
if (!nv_shadow_bios(dev, dev_priv->bios.data))
return -EINVAL;
struct drm_nouveau_private *dev_priv = dev->dev_private;
struct nv50_crtc *crtc = NULL;
struct nv50_display *display = NULL;
+ int rval = 0;
NV50_DEBUG("\n");
crtc->dev = dev;
display = nv50_get_display(dev);
- if (!display)
+ if (!display) {
+ rval = -EINVAL;
goto out;
+ }
list_add_tail(&crtc->head, &display->crtcs);
crtc->mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
crtc->native_mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
+ if (!crtc->mode || crtc->native_mode) {
+ rval = -ENOMEM;
+ goto out;
+ }
+
nv50_fb_create(crtc);
nv50_lut_create(crtc);
nv50_cursor_create(crtc);
if (dev_priv->free_crtc)
dev_priv->free_crtc(crtc);
- return -EINVAL;
+ return rval;
}
return -EINVAL;
crtc->cursor = kzalloc(sizeof(struct nv50_cursor), GFP_KERNEL);
+ if (!crtc->cursor)
+ return -ENOMEM;
/* function pointers */
crtc->cursor->show = nv50_cursor_show;
struct nv50_output *output = NULL;
struct nv50_display *display = NULL;
struct dcb_entry *entry = NULL;
+ int rval = 0;
NV50_DEBUG("\n");
output->dev = dev;
display = nv50_get_display(dev);
- if (!display)
+ if (!display) {
+ rval = -EINVAL;
goto out;
+ }
entry = &dev_priv->dcb_table.entry[dcb_entry];
- if (!entry)
+ if (!entry) {
+ rval = -EINVAL;
goto out;
+ }
switch (entry->type) {
case DCB_OUTPUT_ANALOG:
DRM_INFO("Detected a DAC output\n");
break;
default:
+ rval = -EINVAL;
goto out;
}
list_add_tail(&output->head, &display->outputs);
output->native_mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
+ if (!output->native_mode) {
+ rval = -ENOMEM;
+ goto out;
+ }
/* Set function pointers. */
output->validate_mode = nv50_dac_validate_mode;
kfree(output->native_mode);
if (dev_priv->free_output)
dev_priv->free_output(output);
- return -EINVAL;
+ return rval;
}
NV50_DEBUG("\n");
+ if (!display)
+ return -ENOMEM;
+
INIT_LIST_HEAD(&display->crtcs);
INIT_LIST_HEAD(&display->outputs);
INIT_LIST_HEAD(&display->connectors);
crtc->fb = kzalloc(sizeof(struct nv50_fb), GFP_KERNEL);
+ if (!crtc->fb)
+ return -ENOMEM;
+
crtc->fb->bind = nv50_fb_bind;
return 0;
struct nv50_kms_priv *kms_priv = nv50_get_kms_priv(dev);
struct nv50_kms_crtc *crtc = kzalloc(sizeof(struct nv50_kms_crtc), GFP_KERNEL);
- list_add_tail(&crtc->head, &kms_priv->crtcs);
+ if (!crtc)
+ return NULL;
+
+ list_add_tail(&crtc->item, &kms_priv->crtcs);
return &(crtc->priv);
}
struct nv50_kms_priv *kms_priv = nv50_get_kms_priv(dev);
struct nv50_kms_encoder *encoder = kzalloc(sizeof(struct nv50_kms_encoder), GFP_KERNEL);
- list_add_tail(&encoder->head, &kms_priv->encoders);
+ if (!encoder)
+ return NULL;
+
+ list_add_tail(&encoder->item, &kms_priv->encoders);
return &(encoder->priv);
}
struct nv50_kms_priv *kms_priv = nv50_get_kms_priv(dev);
struct nv50_kms_connector *connector = kzalloc(sizeof(struct nv50_kms_connector), GFP_KERNEL);
- list_add_tail(&connector->head, &kms_priv->connectors);
+ if (!connector)
+ return NULL;
+
+ list_add_tail(&connector->item, &kms_priv->connectors);
return &(connector->priv);
}
{
struct nv50_kms_crtc *kms_crtc = from_nv50_crtc(crtc);
- list_del(&kms_crtc->head);
+ list_del(&kms_crtc->item);
kfree(kms_crtc);
}
{
struct nv50_kms_encoder *kms_encoder = from_nv50_output(output);
- list_del(&kms_encoder->head);
+ list_del(&kms_encoder->item);
kfree(kms_encoder);
}
{
struct nv50_kms_connector *kms_connector = from_nv50_connector(connector);
- list_del(&kms_connector->head);
+ list_del(&kms_connector->item);
kfree(kms_connector);
}
static struct nouveau_hw_mode *nv50_kms_to_hw_mode(struct drm_display_mode *mode)
{
struct nouveau_hw_mode *hw_mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
+ if (!hw_mode)
+ return NULL;
/* create hw values. */
hw_mode->clock = mode->clock;
struct nv50_display *display = NULL;
int rval = 0;
+ if (!kms_priv)
+ return -ENOMEM;
+
dev_priv->kms_priv = kms_priv;
/* function pointers */
/* Link internal modesetting structure to interface. */
struct nv50_kms_crtc {
- struct list_head head;
+ struct list_head item;
struct nv50_crtc priv;
struct drm_crtc pub;
};
struct nv50_kms_encoder {
- struct list_head head;
+ struct list_head item;
struct nv50_output priv;
struct drm_encoder pub;
};
struct nv50_kms_connector {
- struct list_head head;
+ struct list_head item;
struct nv50_connector priv;
struct drm_connector pub;
NV50_DEBUG("\n");
+ if (!file_priv)
+ return -ENOMEM;
+
/* Any file_priv should do as it's pointer is used as identification. */
block = nouveau_mem_alloc(crtc->dev, 0, 4096, flags, file_priv);
crtc->lut = kzalloc(sizeof(struct nv50_lut), GFP_KERNEL);
+ if (!crtc->lut)
+ return -ENOMEM;
+
rval = nv50_lut_alloc(crtc);
if (rval != 0)
return rval;
struct nv50_output *output = NULL;
struct nv50_display *display = NULL;
struct dcb_entry *entry = NULL;
+ int rval = 0;
NV50_DEBUG("\n");
output->dev = dev;
display = nv50_get_display(dev);
- if (!display)
+ if (!display) {
+ rval = -EINVAL;
goto out;
+ }
entry = &dev_priv->dcb_table.entry[dcb_entry];
- if (!entry)
+ if (!entry) {
+ rval = -EINVAL;
goto out;
+ }
switch (entry->type) {
case DCB_OUTPUT_TMDS:
DRM_INFO("Detected a LVDS output\n");
break;
default:
+ rval = -EINVAL;
goto out;
}
list_add_tail(&output->head, &display->outputs);
output->native_mode = kzalloc(sizeof(struct nouveau_hw_mode), GFP_KERNEL);
+ if (!output->native_mode) {
+ rval = -ENOMEM;
+ goto out;
+ }
/* Set function pointers. */
output->validate_mode = nv50_sor_validate_mode;
kfree(output->native_mode);
if (dev_priv->free_output)
dev_priv->free_output(output);
- return -EINVAL;
+ return rval;
}