From patchwork Sun Jul 23 18:16:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9858547 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 C6D95600F5 for ; Sun, 23 Jul 2017 18:17:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0DEC283BF for ; Sun, 23 Jul 2017 18:17:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0C402845C; Sun, 23 Jul 2017 18:17:38 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 424362854F for ; Sun, 23 Jul 2017 18:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751574AbdGWSRB (ORCPT ); Sun, 23 Jul 2017 14:17:01 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36347 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751487AbdGWSQp (ORCPT ); Sun, 23 Jul 2017 14:16:45 -0400 Received: by mail-wm0-f68.google.com with SMTP id 184so10070700wmo.3 for ; Sun, 23 Jul 2017 11:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pZ+c9JiB9Rkt+lYPMC3lwuJyRBUh75jWPWNl1zXVLBE=; b=CLeOh+tMI20keuk7ZZCondp7t6lOTbEj8+P+8U2YBeoKAXARTmW1+w8YXce1EBOLnZ vX+Ymv2R6pgFla8/en8Wi3mAXBr6t4ZapZs/VyMvIexUoyFYjieR7x9PHZOaNr8Pj6OH dNGw2vqKaiRw9kuh5/jIQjr3zaUj9MP20ckKEm/1GC1WFOWBR9iiwxogl3luZo9anZbj 5RoGsgCxECUJ5QH+INDfEbpP3HoKzzp0X0rPOJ3V89aCzJgtsY4ECu/pV+bgfUm7iDkn Z5omMVt8/e77iq1ps3cgNUlebJOwIYC6MN8iX2WgrtZdlpkJXNPUw6phBwnBkA2mfE90 Q77w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pZ+c9JiB9Rkt+lYPMC3lwuJyRBUh75jWPWNl1zXVLBE=; b=ZYWUghj2LwMqCGEc+Cm5jriFZcqmfIi9Tz7BinPeG8hnh7E2Dsceivu8dPCd/K2BFI 9C0QSELx3gKqGx0IJi3TkRvj2mmn0OEtzaHd0q0SBOmqlAVmLIBC8hs81MW4juPlhzKS kJKhx0FVmcBXmFNqZ0vcdGjXD1yWSWpY/XI0Z8poLZuajpWWVXJZieiD4Vu6dMna47Ym pSGeV4Olzt3ZDwWh68rtn7WaWZ4gjmnYFCoouwWvYt2q7F5MkjmemO3BXNRYOd9tnwzX /uQKh8Gui8hjhiM8u2WCYyr8Gq/g8r1HZyuJSLp7rEEg3XQBQFq0KVyMq8Zg5nMNqd8Q Udgg== X-Gm-Message-State: AIVw1103Rm7nh7JkOT408vcQPY7rsAgh8ycB7kBMUHmkPPXDYQ3LwRTZ gLGfbBH9lilp6UsP X-Received: by 10.28.193.138 with SMTP id r132mr3477962wmf.155.1500833803719; Sun, 23 Jul 2017 11:16:43 -0700 (PDT) Received: from dvbdev.wuest.de (ip-84-118-193-88.unity-media.net. [84.118.193.88]) by smtp.gmail.com with ESMTPSA id 93sm13247338wra.82.2017.07.23.11.16.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Jul 2017 11:16:43 -0700 (PDT) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Cc: r.scobie@clear.net.nz, jasmin@anw.at, d_spingler@freenet.de, Manfred.Knick@t-online.de, rjkm@metzlerbros.de Subject: [PATCH RESEND 09/14] [media] ddbridge: fix possible buffer overflow in ddb_ports_init() Date: Sun, 23 Jul 2017 20:16:25 +0200 Message-Id: <20170723181630.19526-10-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170723181630.19526-1-d.scheller.oss@gmail.com> References: <20170723181630.19526-1-d.scheller.oss@gmail.com> 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 From: Daniel Scheller Report from smatch: drivers/media/pci/ddbridge/ddbridge-core.c:2659 ddb_ports_init() error: buffer overflow 'dev->port' 32 <= u32max Fix by making sure "p" is greater than zero before checking for "dev->port[].type == DDB_CI_EXTERNAL_XO2". Cc: Ralph Metzler Signed-off-by: Daniel Scheller Tested-by: Richard Scobie Tested-by: Jasmin Jessich Tested-by: Dietmar Spingler Tested-by: Manfred Knick --- drivers/media/pci/ddbridge/ddbridge-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 1e5c420e4717..5f8f77c74339 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -2550,7 +2550,7 @@ void ddb_ports_init(struct ddb *dev) port->dvb[0].adap = &dev->adap[2 * p]; port->dvb[1].adap = &dev->adap[2 * p + 1]; - if ((port->class == DDB_PORT_NONE) && i && + if ((port->class == DDB_PORT_NONE) && i && p > 0 && dev->port[p - 1].type == DDB_CI_EXTERNAL_XO2) { port->class = DDB_PORT_CI; port->type = DDB_CI_EXTERNAL_XO2_B;