[PATCH 04/18] drivers/ipc: bufp: fix read-write, write-write preemption cases

Jan Kiszka jan.kiszka at siemens.com
Mon Feb 25 19:17:22 CET 2019


On 05.02.19 12:20, Philippe Gerum via Xenomai wrote:
> On 2/4/19 7:55 PM, Jan Kiszka wrote:
>>> -             * Release the lock while copying the data to
>>> -             * keep latency low.
>>> +             * We have to drop the lock while reading in
>>> +             * data, but we can't rollback on bad read
>>> +             * from user because some other thread might
>>> +             * have populated the memory ahead of our
>>> +             * write slot already: bluntly clear the
>>> +             * unavailable bytes on copy error.
>>>                 */
>>>                cobalt_atomic_leave(s);
>>> -            ret = xnbufd_copy_to_kmem(rsk->bufmem + wroff, bufd, n);
>>> -            if (ret < 0)
>>> -                return ret;
>>> +            xret = xnbufd_copy_to_kmem(rsk->bufmem + wroff, bufd, n);
>>>                cobalt_atomic_enter(s);
>>> -            /*
>>> -             * In case we were preempted while copying the
>>> -             * message, we have to write the whole thing
>>> -             * again.
>>> -             */
>>> -            if (rsk->wrtoken != wrtoken) {
>>> -                xnbufd_reset(bufd);
>>> -                goto redo;
>>> +            if (xret < 0) {
>>> +                memset(rsk->bufmem + wroff + n - xret, 0, xret);
>>
>> This looks fishy, to the compiler and also to me.
>>
> Oh, well. Paste&copy blunder, the fix originates from a distinct
> co-kernel implementation. I'll resubmit.
> 

Did I get that update already? I don't think so.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux



More information about the Xenomai mailing list