diff mbox

[1/3] drm: Fix DRM_MINOR limits for control and render nodes

Message ID 1348850159-3956-2-git-send-email-krh@bitplanet.net (mailing list archive)
State New, archived
Headers show

Commit Message

Kristian Hogsberg Sept. 28, 2012, 4:35 p.m. UTC
We got the minor number base right, but limit is too big and causes the
minor numer ranges for the control and render nodes to overlap.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
---
 drivers/gpu/drm/drm_stub.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ilija Hadzic Sept. 28, 2012, 6:16 p.m. UTC | #1
On Fri, 28 Sep 2012, Kristian Høgsberg wrote:


  	if (type == DRM_MINOR_CONTROL) {
                  base += 64;
-                limit = base + 127;
+                limit = base + 64;
          } else if (type == DRM_MINOR_RENDER) {
                  base += 128;
-                limit = base + 255;
+                limit = base + 64;

If my first grade arithmetics serves me well, shouldn't limit in the first 
clause be base + 63 and in the second clause, base + 127. The render 
node starts at 128 and spans to 255, so there are total of 128 render 
nodes, 64 card (legacy) nodes and 64 control nodes allowed.

Actually, this construction of limit relative to the base does not achieve 
anything. The code would be much more readable if it were something like 
this:

 	if (type == DRM_MINOR_CONTROL) {
                 base = 64;
                 limit = 127;
         } else if (type == DRM_MINOR_RENDER) {
                 base = 128;
                 limit = 255;
         }

-- Ilija
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 21bcd4a..d6d5160 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -107,10 +107,10 @@  static int drm_minor_get_id(struct drm_device *dev, int type)
 
 	if (type == DRM_MINOR_CONTROL) {
                 base += 64;
-                limit = base + 127;
+                limit = base + 64;
         } else if (type == DRM_MINOR_RENDER) {
                 base += 128;
-                limit = base + 255;
+                limit = base + 64;
         }
 
 again: