Skip to contentSkip to conversation

small STI patch

parisc-linux Helge Deller 2 participants 3 messages Feb 13, 2001

lore
Share & tools
lore
#0 lore raw

Hi,

I've just committed a small patch, which saves us to copy a whole struct from the STI ROM just to get one value (the ROM size) out of it.

Helge

02/13 20:56:54 1.4 renamed from 02/04 21:22:59 1.3 +2 -6
@@ -119,13 +119,9 @@
        if (!(raw && cooked))
                goto out_err;
 
-       /* copy raw rom header & get the real size */
-       sti_rom_copy(address, 0, sizeof(*raw), raw);
-       wmode_sti_dump_rom(raw);
-       size = raw->last_addr;
-       kfree(raw);
+       /* read the ROM size directly from the struct in ROM */
+       size = gsc_readl(address + offsetof(struct sti_rom,last_addr));
 
-       /* now copy raw rom with real size */
        raw = kmalloc(size, GFP_KERNEL);
        if(!raw)
                goto out_err;
#1 lore raw
Quoted 2 lines · Helge Deller

I've just committed a small patch, which saves us to copy a whole struct from the STI ROM just to get one value (the ROM size) out of it.

But we leak a kmalloc'd buffer. you need to remove the prior kmalloc assigned to raw.

Signature · 1 line
Revolutions do not require corporate support.
#2 lore raw
Quoted 6 lines · Matthew Wilcox
Quoted 2 lines · Helge Deller

I've just committed a small patch, which saves us to copy a whole struct from the STI ROM just to get one value (the ROM size) out of it.

But we leak a kmalloc'd buffer. you need to remove the prior kmalloc assigned to raw.

Yes, you're right.
I've just committed the following patch.

Helge

02/13 21:38:18 renamed from 02/13 20:56:54 1.4 +0 -0
diff -u -r1.4 sticon-wmode.c
@@ -110,13 +110,11 @@
 wmode_sti_read_rom(struct sti_struct *sti, unsigned long address, unsigned 

long hpa)

 {
        struct sti_cooked_rom *cooked;
-       struct sti_rom *raw;
+       struct sti_rom *raw = NULL;
        unsigned long size;

-

        cooked = kmalloc(sizeof *cooked, GFP_KERNEL);
-       raw = kmalloc(sizeof *raw, GFP_KERNEL);
-       if (!(raw && cooked))
+       if (!cooked)
                goto out_err;
 
        /* read the ROM size directly from the struct in ROM */