summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
Diffstat (limited to 'linux-core')
-rw-r--r--linux-core/nouveau_bios.c2
-rw-r--r--linux-core/nv50_crtc.c12
-rw-r--r--linux-core/nv50_cursor.c2
-rw-r--r--linux-core/nv50_dac.c16
-rw-r--r--linux-core/nv50_display.c3
-rw-r--r--linux-core/nv50_fb.c3
-rw-r--r--linux-core/nv50_kms_wrapper.c26
-rw-r--r--linux-core/nv50_kms_wrapper.h6
-rw-r--r--linux-core/nv50_lut.c6
-rw-r--r--linux-core/nv50_sor.c16
10 files changed, 75 insertions, 17 deletions
diff --git a/linux-core/nouveau_bios.c b/linux-core/nouveau_bios.c
index 83647418..3e7fe23f 100644
--- a/linux-core/nouveau_bios.c
+++ b/linux-core/nouveau_bios.c
@@ -532,6 +532,8 @@ int nouveau_parse_bios(struct drm_device *dev)
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;
diff --git a/linux-core/nv50_crtc.c b/linux-core/nv50_crtc.c
index 974f5202..f34e7279 100644
--- a/linux-core/nv50_crtc.c
+++ b/linux-core/nv50_crtc.c
@@ -463,6 +463,7 @@ int nv50_crtc_create(struct drm_device *dev, int index)
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");
@@ -476,8 +477,10 @@ int nv50_crtc_create(struct drm_device *dev, int index)
crtc->dev = dev;
display = nv50_get_display(dev);
- if (!display)
+ if (!display) {
+ rval = -EINVAL;
goto out;
+ }
list_add_tail(&crtc->head, &display->crtcs);
@@ -486,6 +489,11 @@ int nv50_crtc_create(struct drm_device *dev, int index)
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);
@@ -511,5 +519,5 @@ out:
if (dev_priv->free_crtc)
dev_priv->free_crtc(crtc);
- return -EINVAL;
+ return rval;
}
diff --git a/linux-core/nv50_cursor.c b/linux-core/nv50_cursor.c
index 3d35b936..4196df6b 100644
--- a/linux-core/nv50_cursor.c
+++ b/linux-core/nv50_cursor.c
@@ -140,6 +140,8 @@ int nv50_cursor_create(struct nv50_crtc *crtc)
return -EINVAL;
crtc->cursor = kzalloc(sizeof(struct nv50_cursor), GFP_KERNEL);
+ if (!crtc->cursor)
+ return -ENOMEM;
/* function pointers */
crtc->cursor->show = nv50_cursor_show;
diff --git a/linux-core/nv50_dac.c b/linux-core/nv50_dac.c
index f827fed4..b237241e 100644
--- a/linux-core/nv50_dac.c
+++ b/linux-core/nv50_dac.c
@@ -122,6 +122,7 @@ int nv50_dac_create(struct drm_device *dev, int dcb_entry)
struct nv50_output *output = NULL;
struct nv50_display *display = NULL;
struct dcb_entry *entry = NULL;
+ int rval = 0;
NV50_DEBUG("\n");
@@ -135,12 +136,16 @@ int nv50_dac_create(struct drm_device *dev, int dcb_entry)
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:
@@ -148,6 +153,7 @@ int nv50_dac_create(struct drm_device *dev, int dcb_entry)
DRM_INFO("Detected a DAC output\n");
break;
default:
+ rval = -EINVAL;
goto out;
}
@@ -157,6 +163,10 @@ int nv50_dac_create(struct drm_device *dev, int dcb_entry)
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;
@@ -172,6 +182,6 @@ out:
kfree(output->native_mode);
if (dev_priv->free_output)
dev_priv->free_output(output);
- return -EINVAL;
+ return rval;
}
diff --git a/linux-core/nv50_display.c b/linux-core/nv50_display.c
index 56ddeb97..05ff72f8 100644
--- a/linux-core/nv50_display.c
+++ b/linux-core/nv50_display.c
@@ -189,6 +189,9 @@ int nv50_display_create(struct drm_device *dev)
NV50_DEBUG("\n");
+ if (!display)
+ return -ENOMEM;
+
INIT_LIST_HEAD(&display->crtcs);
INIT_LIST_HEAD(&display->outputs);
INIT_LIST_HEAD(&display->connectors);
diff --git a/linux-core/nv50_fb.c b/linux-core/nv50_fb.c
index b44b48ab..f57a9fad 100644
--- a/linux-core/nv50_fb.c
+++ b/linux-core/nv50_fb.c
@@ -119,6 +119,9 @@ int nv50_fb_create(struct nv50_crtc *crtc)
crtc->fb = kzalloc(sizeof(struct nv50_fb), GFP_KERNEL);
+ if (!crtc->fb)
+ return -ENOMEM;
+
crtc->fb->bind = nv50_fb_bind;
return 0;
diff --git a/linux-core/nv50_kms_wrapper.c b/linux-core/nv50_kms_wrapper.c
index 01d4bc9a..a63cb7df 100644
--- a/linux-core/nv50_kms_wrapper.c
+++ b/linux-core/nv50_kms_wrapper.c
@@ -48,7 +48,10 @@ static void *nv50_kms_alloc_crtc(struct drm_device *dev)
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);
}
@@ -58,7 +61,10 @@ static void *nv50_kms_alloc_output(struct drm_device *dev)
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);
}
@@ -68,7 +74,10 @@ static void *nv50_kms_alloc_connector(struct drm_device *dev)
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);
}
@@ -77,7 +86,7 @@ static void nv50_kms_free_crtc(void *crtc)
{
struct nv50_kms_crtc *kms_crtc = from_nv50_crtc(crtc);
- list_del(&kms_crtc->head);
+ list_del(&kms_crtc->item);
kfree(kms_crtc);
}
@@ -86,7 +95,7 @@ static void nv50_kms_free_output(void *output)
{
struct nv50_kms_encoder *kms_encoder = from_nv50_output(output);
- list_del(&kms_encoder->head);
+ list_del(&kms_encoder->item);
kfree(kms_encoder);
}
@@ -95,7 +104,7 @@ static void nv50_kms_free_connector(void *connector)
{
struct nv50_kms_connector *kms_connector = from_nv50_connector(connector);
- list_del(&kms_connector->head);
+ list_del(&kms_connector->item);
kfree(kms_connector);
}
@@ -107,6 +116,8 @@ static void nv50_kms_free_connector(void *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;
@@ -870,6 +881,9 @@ int nv50_kms_init(struct drm_device *dev)
struct nv50_display *display = NULL;
int rval = 0;
+ if (!kms_priv)
+ return -ENOMEM;
+
dev_priv->kms_priv = kms_priv;
/* function pointers */
diff --git a/linux-core/nv50_kms_wrapper.h b/linux-core/nv50_kms_wrapper.h
index 3847d510..f224f1bb 100644
--- a/linux-core/nv50_kms_wrapper.h
+++ b/linux-core/nv50_kms_wrapper.h
@@ -44,21 +44,21 @@
/* 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;
diff --git a/linux-core/nv50_lut.c b/linux-core/nv50_lut.c
index 570900ba..cb52f27f 100644
--- a/linux-core/nv50_lut.c
+++ b/linux-core/nv50_lut.c
@@ -37,6 +37,9 @@ static int nv50_lut_alloc(struct nv50_crtc *crtc)
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);
@@ -137,6 +140,9 @@ int nv50_lut_create(struct nv50_crtc *crtc)
crtc->lut = kzalloc(sizeof(struct nv50_lut), GFP_KERNEL);
+ if (!crtc->lut)
+ return -ENOMEM;
+
rval = nv50_lut_alloc(crtc);
if (rval != 0)
return rval;
diff --git a/linux-core/nv50_sor.c b/linux-core/nv50_sor.c
index 430c1e83..49f29fd3 100644
--- a/linux-core/nv50_sor.c
+++ b/linux-core/nv50_sor.c
@@ -138,6 +138,7 @@ int nv50_sor_create(struct drm_device *dev, int dcb_entry)
struct nv50_output *output = NULL;
struct nv50_display *display = NULL;
struct dcb_entry *entry = NULL;
+ int rval = 0;
NV50_DEBUG("\n");
@@ -151,12 +152,16 @@ int nv50_sor_create(struct drm_device *dev, int dcb_entry)
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:
@@ -168,6 +173,7 @@ int nv50_sor_create(struct drm_device *dev, int dcb_entry)
DRM_INFO("Detected a LVDS output\n");
break;
default:
+ rval = -EINVAL;
goto out;
}
@@ -177,6 +183,10 @@ int nv50_sor_create(struct drm_device *dev, int dcb_entry)
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;
@@ -200,5 +210,5 @@ out:
kfree(output->native_mode);
if (dev_priv->free_output)
dev_priv->free_output(output);
- return -EINVAL;
+ return rval;
}