lkml.org 
[lkml]   [2011]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: flex_array related problems on selinux policy loading
    From
    Date
    On Wed, 2011-01-26 at 14:04 +0100, Steffen Klassert wrote:
    > Another thing came to my mind. An atempt to do a zero size allocation
    > always succeed on kmalloc. If we want to allocate our metadata even in
    > this case, we should be aware that this allocation _can_ fail. So
    > flex_array_alloc would not show the same behaviour as kmalloc on zero
    > size allocations.

    I think that's just fine.

    You have to check for and handle those allocation failures anyway. Can
    you think of places in the kernel where we have known-zero-sized
    allocations that don't check kmalloc() returns?

    > As most potential flex_array users convert their code
    > from kmalloc, the behaviour of flex_array_alloc should be the same as of
    > kmalloc. Showing a different behaviour here will produce pitfalls for
    > potential new users. Also, to tell a user that we can not allocate memory
    > for him, if the wants to allocate 0 byte (nothing) is quite odd. This
    > user could easily continue processing, even if we can not allocate our
    > metadata in this moment.

    This doesn't have to be a one to one, direct, replacement for kmalloc().
    As long as it's close enough not to confuse people or normally cause
    problems, I think it's fine.
    -- Dave



    \
     
     \ /
      Last update: 2011-01-26 17:19    [W:0.022 / U:0.160 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site