Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759394AbbLBRUd (ORCPT ); Wed, 2 Dec 2015 12:20:33 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:43876 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933281AbbLBRBm (ORCPT ); Wed, 2 Dec 2015 12:01:42 -0500 From: Kamal Mostafa To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Ezequiel Garcia , Mauro Carvalho Chehab , Kamal Mostafa Subject: [PATCH 3.19.y-ckt 122/164] vivid: Fix iteration in driver removal path Date: Wed, 2 Dec 2015 08:59:33 -0800 Message-Id: <1449075615-20754-123-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449075615-20754-1-git-send-email-kamal@canonical.com> References: <1449075615-20754-1-git-send-email-kamal@canonical.com> X-Extended-Stable: 3.19 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1661 Lines: 49 3.19.8-ckt11 -stable review patch. If anyone has any objections, please let me know. ------------------ From: Ezequiel Garcia commit a5d42b8c3b3ddccd88dc1c70957177d31a6699fb upstream. 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 Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Kamal Mostafa --- drivers/media/platform/vivid/vivid-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c index a7e033a..d801b57 100644 --- a/drivers/media/platform/vivid/vivid-core.c +++ b/drivers/media/platform/vivid/vivid-core.c @@ -1314,8 +1314,11 @@ static void __exit vivid_exit(void) 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", -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/