dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Prarit Bhargava <prarit@redhat.com>
To: Maarten Maathuis <madman2003@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH]: nouveau and radeon checkstack fixes
Date: Sat, 22 May 2010 19:07:55 -0400	[thread overview]
Message-ID: <4BF863CB.2000504@redhat.com> (raw)
In-Reply-To: <AANLkTilGu5wk9TZqTN0XioQyZUYASYgrm13FX33jE0CN@mail.gmail.com>

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



On 05/22/2010 03:57 PM, Maarten Maathuis wrote:
> On Sat, May 22, 2010 at 2:30 AM, Prarit Bhargava<prarit@redhat.com>  wrote:
>    
>> Fixes linux-next&  linux-2.6 checkstack warnings:
>>
>> drivers/gpu/drm/nouveau/nv40_graph.c: In function `nv40_graph_init':
>> drivers/gpu/drm/nouveau/nv40_graph.c:400: warning: the frame size of 1184 bytes is larger than 1024 bytes
>> drivers/gpu/drm/radeon/radeon_atombios.c: In function `radeon_get_atom_connector_info_from_supported_devices_table':
>> drivers/gpu/drm/radeon/radeon_atombios.c:857: warning: the frame size of 1872 bytes is larger than 1024 bytes
>>
>> Signed-off-by: Prarit Bhargava<prarit@redhat.com>
>>
>> diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c
>> index 0616c96..3604394 100644
>> --- a/drivers/gpu/drm/nouveau/nv40_graph.c
>> +++ b/drivers/gpu/drm/nouveau/nv40_graph.c
>> @@ -253,7 +253,11 @@ nv40_graph_init(struct drm_device *dev)
>>
>>         if (!dev_priv->engine.graph.ctxprog) {
>>                 struct nouveau_grctx ctx = {};
>> -               uint32_t cp[256];
>> +               uint32_t *cp;
>> +
>> +               cp = kmalloc(sizeof(*cp), GFP_KERNEL);
>> +               if (!cp)
>> +                       return -ENOMEM;
>>
>>      
> This seems wrong, allocating 1 uint32_t isn't enough.
>    

Oops!  That obviously should have been (sizeof(*cp) * 256) ... New patch.

Thanks Maarten,

P.

>    
>>                 ctx.dev = dev;
>>                 ctx.mode = NOUVEAU_GRCTX_PROG;
>> @@ -265,6 +269,8 @@ nv40_graph_init(struct drm_device *dev)
>>                 nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
>>                 for (i = 0; i<  ctx.ctxprog_len; i++)
>>                         nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp[i]);
>> +
>> +               kfree(cp);
>>         }
>>
>>         /* No context present currently */
>> diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
>> index 1d05deb..5ad208c 100644
>> --- a/drivers/gpu/drm/radeon/radeon_atombios.c
>> +++ b/drivers/gpu/drm/radeon/radeon_atombios.c
>> @@ -682,10 +682,18 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
>>         uint8_t dac;
>>         union atom_supported_devices *supported_devices;
>>         int i, j, max_device;
>> -       struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE];
>> +       struct bios_connector *bios_connectors;
>> +       size_t bc_size = sizeof(*bios_connectors) * ATOM_MAX_SUPPORTED_DEVICE;
>>
>> -       if (!atom_parse_data_header(ctx, index,&size,&frev,&crev,&data_offset))
>> +       bios_connectors = kzalloc(bc_size, GFP_KERNEL);
>> +       if (!bios_connectors)
>> +               return false;
>> +
>> +       if (!atom_parse_data_header(ctx, index,&size,&frev,&crev,
>> +&data_offset)) {
>> +               kfree(bios_connectors);
>>                 return false;
>> +       }
>>
>>         supported_devices =
>>             (union atom_supported_devices *)(ctx->bios + data_offset);
>> @@ -853,6 +861,7 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
>>
>>         radeon_link_encoder_connector(dev);
>>
>> +       kfree(bios_connectors);
>>         return true;
>>   }
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>>      

[-- Attachment #2: drm.patch --]
[-- Type: text/plain, Size: 2492 bytes --]

Fixes linux-next & linux-2.6 checkstack warnings:

drivers/gpu/drm/nouveau/nv40_graph.c: In function `nv40_graph_init':
drivers/gpu/drm/nouveau/nv40_graph.c:400: warning: the frame size of 1184 bytes is larger than 1024 bytes
drivers/gpu/drm/radeon/radeon_atombios.c: In function `radeon_get_atom_connector_info_from_supported_devices_table':
drivers/gpu/drm/radeon/radeon_atombios.c:857: warning: the frame size of 1872 bytes is larger than 1024 bytes

Signed-off-by: Prarit Bhargava <prarit@redhat.com>

diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c
index 0616c96..704a25d 100644
--- a/drivers/gpu/drm/nouveau/nv40_graph.c
+++ b/drivers/gpu/drm/nouveau/nv40_graph.c
@@ -253,7 +253,11 @@ nv40_graph_init(struct drm_device *dev)
 
 	if (!dev_priv->engine.graph.ctxprog) {
 		struct nouveau_grctx ctx = {};
-		uint32_t cp[256];
+		uint32_t *cp;
+
+		cp = kmalloc(sizeof(*cp) * 256, GFP_KERNEL);
+		if (!cp)
+			return -ENOMEM;
 
 		ctx.dev = dev;
 		ctx.mode = NOUVEAU_GRCTX_PROG;
@@ -265,6 +269,8 @@ nv40_graph_init(struct drm_device *dev)
 		nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
 		for (i = 0; i < ctx.ctxprog_len; i++)
 			nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp[i]);
+
+		kfree(cp);
 	}
 
 	/* No context present currently */
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 1d05deb..02697e2 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -682,10 +682,18 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
 	uint8_t dac;
 	union atom_supported_devices *supported_devices;
 	int i, j, max_device;
-	struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE];
+	struct bios_connector *bios_connectors;
+	size_t bc_size = sizeof(*bios_connectors) * ATOM_MAX_SUPPORTED_DEVICE;
 
-	if (!atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
+	bios_connectors = kzalloc(bc_size, GFP_KERNEL);
+	if (!bios_connectors)
+		return false;
+
+	if (!atom_parse_data_header(ctx, index, &size, &frev, &crev,
+				    &data_offset)) {
+		kfree(bios_connectors);
 		return false;
+	}
 
 	supported_devices =
 	    (union atom_supported_devices *)(ctx->bios + data_offset);
@@ -853,6 +861,7 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
 
 	radeon_link_encoder_connector(dev);
 
+	kfree(bios_connectors);
 	return true;
 }
 
* Unmerged path localversion-next

[-- Attachment #3: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2010-05-22 23:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-22  0:30 [PATCH]: nouveau and radeon checkstack fixes Prarit Bhargava
2010-05-22 19:57 ` Maarten Maathuis
2010-05-22 23:07   ` Prarit Bhargava [this message]

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=4BF863CB.2000504@redhat.com \
    --to=prarit@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=madman2003@gmail.com \
    /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