media: v4l: subdev: Prevent NULL routes access

When using v4l2_subdev_set_routing to set a subdev's
routing, and the passed routing.num_routes is 0,
kmemdup is not called to populate the routes of the
new routing (which is fine, since we wouldn't want to
pass a possible NULL value to kmemdup).

This results in subdev's routing.routes to be NULL.

routing.routes is further used in some places without
being guarded by the same num_routes non-zero condition.

Fix it.

Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
1 file changed