Before return adds correct cleanup part and code will be same as my
original patch.

So if more people think that your code is cleaner I'm OK with replacing
it.

> If I understand correctly, the second check on the first line added
> by your patch prevents a bad dereference when accesing
> buffer_entry[0].

Yes. Same check (buffer_entry < buffer_end) is used in next whole loop,
so I uses it in my patch too...

> The only case when that may happen is when
> buffer_size is 0,

In this one case, yes. But you can see that buffer_entry variable is
changing (increasing pointer offset), it means that it points to some
entry in buffer.

> which means we got notified with rubbish anyway,
> so we can just return (perhaps with a log message, which I omitted
> above).
>
> One more minor nit: you should probably decide between "first" and
> "one" as the phrase "only first one event" (found both in the commit
> message and in the code comment) sounds incorrect to me.

Feel free to correct commit message, I'm not very good in english...

It should mean something like this... in buffer received by bios can be
more events. That while loop iterate over events. And this my patch on
machines with wmi version 0 will process only *one* event. And that
event is *first* in buffer.

--
Pali RohÃr
pali.rohar@xxxxxxxxx

Attachment:
signature.ascDescription: This is a digitally signed message part.