re: media: rcar-vin: add group allocator functions

From: Colin Ian King
Date: Wed May 02 2018 - 04:46:10 EST


Hi there,

Static analysis with CoverityScan picked up an explicit null pointer
dereference in the the following commit:

commit 3bb4c3bc85bf77a76c921671800bde2e1bf82a88
Author: Niklas SÃderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
Date: Sat Apr 14 07:57:18 2018 -0400

media: rcar-vin: add group allocator functions

in:

+static void rvin_group_put(struct rvin_dev *vin)
+{
+ mutex_lock(&vin->group->lock);
+
+ vin->group = NULL;

vin->group is now NULL


+ vin->v4l2_dev.mdev = NULL;
+
+ if (WARN_ON(vin->group->vin[vin->id] != vin))
+ goto out;

vin->group is being dereferenced (null pointer dereference)

+
+ vin->group->vin[vin->id] = NULL;

vin->group is being dereferenced (null pointer dereference)

+out:
+ mutex_unlock(&vin->group->lock);
+
+ kref_put(&vin->group->refcount, rvin_group_release);
+}

So I think this needs fixing up.

Regards,

Colin