linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jacobs <aurel@gnuage.org>
To: linux-fbdev-devel@lists.sourceforge.net
Subject: [PATCH] vesafb memory size mismatch
Date: Fri, 1 Oct 2004 15:36:24 +0200	[thread overview]
Message-ID: <20041001153624.267a808b@homer.gnuage.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 999 bytes --]

Hi,

I found a bug in the vesafb driver. The video memory size which is
reserved by vesafb do not correspond to the really needed memory.
Currently the needed memory is calculated using
screen_info.lfb_width * vesafb_defined.bits_per_pixel >> 3
This works with most cards because it's usually equal to
vesafb_fix.line_length.
But with some cards (voodoo3 in 24 bits mode) line_length is
greater than width * bytes_per_pixel (probably for alignment
purpose, line_length = 4096 on voodoo3 800x600-24).
Su currently, with such cards, writting in the second buffer
(as memory is allocated for double buffering) can go past the
end of reserved memory, overwritting some other memory area
and leading to a kernel crash.

So I wrote this tiny patch wich correct this bug.
I tested it successfully with different video cards (Matrox,
Nvidia, Sis, 3dfx) in different modes.

I don't know if it's the right place to send a patch for vesafb ?
Could you please direct me to the right place if it's not ?

Aurel

[-- Attachment #2: vesafb-memory.diff --]
[-- Type: text/plain, Size: 696 bytes --]

diff -Naur linux-2.6.8.1.orig/drivers/video/vesafb.c linux-2.6.8.1/drivers/video/vesafb.c
--- linux-2.6.8.1.orig/drivers/video/vesafb.c	2004-09-29 17:47:41.997524992 +0200
+++ linux-2.6.8.1/drivers/video/vesafb.c	2004-09-29 17:48:03.946188288 +0200
@@ -234,7 +234,7 @@
 	vesafb_fix.line_length = screen_info.lfb_linelength;
 
 	/* Allocate enough memory for double buffering */
-	vesafb_fix.smem_len = screen_info.lfb_width * screen_info.lfb_height * vesafb_defined.bits_per_pixel >> 2;
+	vesafb_fix.smem_len = 2 * screen_info.lfb_linelength * screen_info.lfb_height;
 
 	/* check that we don't remap more memory than old cards have */
 	if (vesafb_fix.smem_len > (screen_info.lfb_size * 65536))

             reply	other threads:[~2004-10-01 14:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-01 13:36 Aurelien Jacobs [this message]
2004-10-01 15:48 ` [PATCH] vesafb memory size mismatch Gerd Knorr
2004-10-01 20:22   ` [Linux-fbdev-devel] " Antonino A. Daplas
2004-10-04  9:27     ` Gerd Knorr
2004-10-03  0:53   ` Aurelien Jacobs
2004-10-03  1:59     ` Andrew Morton
2004-10-03  8:46       ` Antonino A. Daplas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041001153624.267a808b@homer.gnuage.org \
    --to=aurel@gnuage.org \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).