]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
[media] vivid: Fix iteration in driver removal path
authorEzequiel Garcia <ezequiel@vanguardiasur.com.ar>
Mon, 28 Sep 2015 21:36:51 +0000 (18:36 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sat, 3 Oct 2015 14:35:44 +0000 (11:35 -0300)
When the diver is removed and all the resources are deallocated,
we should be iterating through the created devices only.

Currently, the iteration ends when vivid_devs[i] is NULL. Since
the array contains VIVID_MAX_DEVS elements, it will oops if
n_devs=VIVID_MAX_DEVS because in that case, no element is NULL.

Fixes: c88a96b023d8 ('[media] vivid: add core driver code')
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/vivid/vivid-core.c

index a047b47167417339bf501286d4ba3d9e3f76894e..0f5e9143cc7ea25930d31c1639daf5670a13d2df 100644 (file)
@@ -1341,8 +1341,11 @@ static int vivid_remove(struct platform_device *pdev)
        struct vivid_dev *dev;
        unsigned i;
 
-       for (i = 0; vivid_devs[i]; i++) {
+
+       for (i = 0; i < n_devs; i++) {
                dev = vivid_devs[i];
+               if (!dev)
+                       continue;
 
                if (dev->has_vid_cap) {
                        v4l2_info(&dev->v4l2_dev, "unregistering %s\n",