summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrice Mandin <pmandin@caramail.com>2007-08-23 10:18:34 +0200
committerPatrice Mandin <pmandin@caramail.com>2007-08-23 10:20:44 +0200
commit98750111961a5729eba9433b927f8c24548fbace (patch)
treee2dc12243ffe6e7d0c01789b4c857ff5deb0242f
parent8645dac8952473dc3e09ba7a7a9db3fbdf75215f (diff)
nouveau: nv10: check some NULL pointers inside context switch
-rw-r--r--shared-core/nv10_graph.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/shared-core/nv10_graph.c b/shared-core/nv10_graph.c
index 53b93758..567ce6a4 100644
--- a/shared-core/nv10_graph.c
+++ b/shared-core/nv10_graph.c
@@ -578,16 +578,40 @@ int nv10_graph_save_context(struct nouveau_channel *chan)
void nouveau_nv10_context_switch(struct drm_device *dev)
{
- struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct drm_nouveau_private *dev_priv;
struct nouveau_channel *next, *last;
int chid;
+ if (!dev) {
+ DRM_DEBUG("Invalid drm_device\n");
+ return;
+ }
+ dev_priv = dev->dev_private;
+ if (!dev_priv) {
+ DRM_DEBUG("Invalid drm_nouveau_private\n");
+ return;
+ }
+ if (!dev_priv->fifos) {
+ DRM_DEBUG("Invalid drm_nouveau_private->fifos\n");
+ return;
+ }
+
chid = NV_READ(NV03_PFIFO_CACHE1_PUSH1)&(nouveau_fifo_number(dev)-1);
next = dev_priv->fifos[chid];
+ if (!next) {
+ DRM_DEBUG("Invalid next channel\n");
+ return;
+ }
+
chid = (NV_READ(NV10_PGRAPH_CTX_USER) >> 24) & (nouveau_fifo_number(dev)-1);
last = dev_priv->fifos[chid];
+ if (!last) {
+ DRM_DEBUG("Invalid last channel\n");
+ return;
+ }
+
DRM_INFO("NV: PGRAPH context switch interrupt channel %x -> %x\n",
last->id, next->id);
@@ -607,7 +631,7 @@ void nouveau_nv10_context_switch(struct drm_device *dev)
nouveau_wait_for_idle(dev);
nv10_graph_load_context(next);
-
+
NV_WRITE(NV10_PGRAPH_CTX_CONTROL, 0x10010100);
NV_WRITE(NV10_PGRAPH_CTX_USER, next->id << 24);
NV_WRITE(NV10_PGRAPH_FFINTFC_ST2, NV_READ(NV10_PGRAPH_FFINTFC_ST2)&0xCFFFFFFF);