Hi list,

currently the drm does not use the return values of several methods.
This patch tries to add some checks. But I guess it's completely
wrong :-)

Regards,
  Christoph Brill
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index ff9b29e..9dd0038 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -329,9 +329,11 @@ int drm_init(struct drm_driver *driver,
 		}
 	}
 
-	if (!drm_fb_loaded)
-		pci_register_driver(&driver->pci_driver);
-	else {
+	if (!drm_fb_loaded) {
+		if (pci_register_driver(&driver->pci_driver) < 0) {
+			DRM_ERROR("could not pci_register_driver\n");
+		}
+	} else {
 		for (i = 0; pciidlist[i].vendor != 0; i++) {
 			pid = &pciidlist[i];
 
diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c
index 348cd2c..e20bfce 100644
--- a/linux-core/drm_stub.c
+++ b/linux-core/drm_stub.c
@@ -233,10 +233,16 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 
 	if (!drm_fb_loaded) {
 		pci_set_drvdata(pdev, dev);
-		pci_request_regions(pdev, driver->pci_driver.name);
+		if (pci_request_regions(pdev, driver->pci_driver.name) < 0) {
+			DRM_ERROR("could not pci_request_regions\n");
+			return -ENOMEM;
+		}
 	}
 
-	pci_enable_device(pdev);
+	if (!pci_enable_device(pdev)) {
+		 DRM_ERROR("could not pci_enable_device\n");
+		 return -ENOMEM;
+	}
 	pci_set_master(pdev);
 
 	if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
diff --git a/linux-core/drm_sysfs.c b/linux-core/drm_sysfs.c
index ace0778..182a195 100644
--- a/linux-core/drm_sysfs.c
+++ b/linux-core/drm_sysfs.c
@@ -93,7 +93,11 @@ struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name)
 	retval = class_register(&cs->class);
 	if (retval)
 		goto error;
-	class_create_file(&cs->class, &class_attr_version);
+	if (class_create_file(&cs->class, &class_attr_version) < 0) {
+		DRM_ERROR("could not class_create_file\n");
+		retval = -ENOMEM;
+		goto error;
+	}
 
 	return cs;
 
@@ -170,11 +174,20 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
 	if (retval)
 		goto error;
 
-	class_device_create_file(&s_dev->class_dev, &cs->attr);
+	if (class_device_create_file(&s_dev->class_dev, &cs->attr) < 0) {
+		DRM_ERROR("could not class_device_create_file\n");
+		retval = -ENOMEM;
+		goto error;
+	}
+		
 	class_set_devdata(&s_dev->class_dev, head);
 
 	for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
-		class_device_create_file(&s_dev->class_dev, &class_device_attrs[i]);
+		if (class_device_create_file(&s_dev->class_dev, &class_device_attrs[i]) < 0) {
+			DRM_ERROR("could not class_device_create_file\n");
+			retval = -ENOMEM;
+			goto error;
+		}
 
 	return &s_dev->class_dev;
 
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to