• Stanislaw Gruszka's avatar
    genetlink: fix counting regression on ctrl_dumpfamily() · 1d2a6a5e
    Stanislaw Gruszka authored
    Commit 2ae0f17d ("genetlink: use idr to track families") replaced
    
    	if (++n < fams_to_skip)
    		continue;
    into:
    
    	if (n++ < fams_to_skip)
    		continue;
    
    This subtle change cause that on retry ctrl_dumpfamily() call we omit
    one family that failed to do ctrl_fill_info() on previous call, because
    cb->args[0] = n number counts also family that failed to do
    ctrl_fill_info().
    
    Patch fixes the problem and avoid confusion in the future just decrease
    n counter when ctrl_fill_info() fail.
    
    User visible problem caused by this bug is failure to get access to
    some genetlink family i.e. nl80211. However problem is reproducible
    only if number of registered genetlink families is big enough to
    cause second call of ctrl_dumpfamily().
    
    Cc: Xose Vazquez Perez <xose.vazquez@gmail.com>
    Cc: Larry Finger <Larry.Finger@lwfinger.net>
    Cc: Johannes Berg <johannes@sipsolutions.net>
    Fixes: 2ae0f17d ("genetlink: use idr to track families")
    Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
    Acked-by: default avatarJohannes Berg <johannes@sipsolutions.net>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    1d2a6a5e
genetlink.c 25.2 KB