From patchwork Wed Jul 18 14:13:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vasilyev X-Patchwork-Id: 10532623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4A7D76020A for ; Wed, 18 Jul 2018 14:21:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E8E62975D for ; Wed, 18 Jul 2018 14:21:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CB6D297C9; Wed, 18 Jul 2018 14:21:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E177A29840 for ; Wed, 18 Jul 2018 14:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730505AbeGRO7b (ORCPT ); Wed, 18 Jul 2018 10:59:31 -0400 Received: from bran.ispras.ru ([83.149.199.196]:23119 "EHLO smtp.ispras.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726181AbeGRO7b (ORCPT ); Wed, 18 Jul 2018 10:59:31 -0400 X-Greylist: delayed 422 seconds by postgrey-1.27 at vger.kernel.org; Wed, 18 Jul 2018 10:59:30 EDT Received: from myklebust.intra.ispras.ru (unknown [10.10.2.207]) by smtp.ispras.ru (Postfix) with ESMTP id 02CEA203B2; Wed, 18 Jul 2018 17:14:17 +0300 (MSK) From: Anton Vasilyev To: Mauro Carvalho Chehab Cc: Anton Vasilyev , Sean Young , Hans Verkuil , Arvind Yadav , "Gustavo A. R. Silva" , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] media: dm1105: Limit number of cards to avoid buffer over read Date: Wed, 18 Jul 2018 17:13:56 +0300 Message-Id: <20180718141356.2515-1-vasilyev@ispras.ru> X-Mailer: git-send-email 2.18.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dm1105_probe() counts number of cards at dm1105_devcount, but missed bounds check before dereference a card array. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev --- drivers/media/pci/dm1105/dm1105.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c index c9db108751a7..1ddb0576fb7b 100644 --- a/drivers/media/pci/dm1105/dm1105.c +++ b/drivers/media/pci/dm1105/dm1105.c @@ -986,6 +986,9 @@ static int dm1105_probe(struct pci_dev *pdev, int ret = -ENOMEM; int i; + if (dm1105_devcount >= ARRAY_SIZE(card)) + return -ENODEV; + dev = kzalloc(sizeof(struct dm1105_dev), GFP_KERNEL); if (!dev) return -ENOMEM;