devlink: Fix list access without lock while reading region
authorParav Pandit <parav@mellanox.com>
Tue, 12 Feb 2019 20:24:08 +0000 (14:24 -0600)
committerDavid S. Miller <davem@davemloft.net>
Thu, 14 Feb 2019 16:45:39 +0000 (11:45 -0500)
commitdac7c08f988bbc7208fc7403a5d75d4bb791139c
tree8e7656b635d933726902556ed2c4a02546b390eb
parentfdd41ec21e150113e8fe169783db9b2030f5491b
devlink: Fix list access without lock while reading region

While finding the devlink device during region reading,
devlink device list is accessed and devlink device is
returned without holding a lock. This could lead to use-after-free
accesses.

While at it, add lockdep assert to ensure that all future callers hold
the lock when calling devlink_get_from_attrs().

Fixes: 4e54795a27f5 ("devlink: Add support for region snapshot read command")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/devlink.c