Skip to contentSkip to conversation

something odd in emu10k1/emufx

DISCUSSION Al Viro 2 participants 2 messages Jan 19, 2008

lore
Share & tools
lore

Al Viro

author
#0 lore raw

In copy_tlv() we have

        tlv = kmalloc(data[1] * 4 + sizeof(data), GFP_KERNEL);
        if (!tlv)
                return NULL;
        memcpy(tlv, data, sizeof(data));
        if (copy_from_user(tlv + 2, _tlv + 2, data[1])) {
                kfree(tlv);
                return NULL;
        }

which looks rather odd, since either we kmalloc too much or copy too little... Comments?

#1 lore raw

At Sat, 19 Jan 2008 02:16:14 +0000,

Quoted 10 lines · Al Viro

In copy_tlv() we have

        tlv = kmalloc(data[1] * 4 + sizeof(data), GFP_KERNEL);
        if (!tlv)
                return NULL;
        memcpy(tlv, data, sizeof(data));
        if (copy_from_user(tlv + 2, _tlv + 2, data[1])) {
                kfree(tlv);
                return NULL;
        }
Quoted 2 lines

which looks rather odd, since either we kmalloc too much or copy too little... Comments?

It's the former case. The total length should be data[1] + sizeof(data). I fixed on ALSA tree now.

Thanks,

Takashi