• Davide Caratti's avatar
    net/sched: fix idr leak in the error path of tcp_pedit_init() · 94fa3f92
    Davide Caratti authored
    tcf_pedit_init() can fail to allocate 'keys' after the idr has been
    successfully reserved. When this happens, subsequent attempts to configure
    a pedit rule using the same idr value systematically fail with -ENOSPC:
    
     # tc action add action pedit munge ip ttl set 63 index 100
     RTNETLINK answers: Cannot allocate memory
     We have an error talking to the kernel
     # tc action add action pedit munge ip ttl set 63 index 100
     RTNETLINK answers: No space left on device
     We have an error talking to the kernel
     # tc action add action pedit munge ip ttl set 63 index 100
     RTNETLINK answers: No space left on device
     We have an error talking to the kernel
     ...
    
    Fix this in the error path of tcf_act_pedit_init(), calling
    tcf_idr_release() in place of tcf_idr_cleanup().
    
    Fixes: 65a206c0 ("net/sched: Change act_api and act_xxx modules to use IDR")
    Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
    Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    94fa3f92
act_pedit.c 10.7 KB