• P
    switchdev: SWITCHDEV_OBJ_PORT_{VLAN, MDB}(): Sanitize · ec394af5
    Petr Machata 提交于
    The two macros SWITCHDEV_OBJ_PORT_VLAN() and SWITCHDEV_OBJ_PORT_MDB()
    expand to a container_of() call, yielding an appropriate container of
    their sole argument. However, due to a name collision, the first
    argument, i.e. the contained object pointer, is not the only one to get
    expanded. The third argument, which is a structure member name, and
    should be kept literal, gets expanded as well. The only safe way to use
    these two macros is therefore to name the local variable passed to them
    "obj".
    
    To fix this, rename the sole argument of the two macros from
    "obj" (which collides with the member name) to "OBJ". Additionally,
    instead of passing "OBJ" to container_of() verbatim, parenthesize it, so
    that a comma in the passed-in expression doesn't pollute the
    container_of() invocation.
    Signed-off-by: NPetr Machata <petrm@mellanox.com>
    Acked-by: NJiri Pirko <jiri@mellanox.com>
    Reviewed-by: NIdo Schimmel <idosch@mellanox.com>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    ec394af5
switchdev.h 6.7 KB