From patchwork Wed Aug 9 20:31:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9891957 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 74E98602D7 for ; Wed, 9 Aug 2017 20:31:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67A2B28AA2 for ; Wed, 9 Aug 2017 20:31:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BD8C28AAE; Wed, 9 Aug 2017 20:31:58 +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 EC17428AA2 for ; Wed, 9 Aug 2017 20:31:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752093AbdHIUbm (ORCPT ); Wed, 9 Aug 2017 16:31:42 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35192 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752050AbdHIUbi (ORCPT ); Wed, 9 Aug 2017 16:31:38 -0400 Received: by mail-wm0-f67.google.com with SMTP id r77so754092wmd.2 for ; Wed, 09 Aug 2017 13:31:37 -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=/lrMP3yXxmBapUCsKeGNyUtChyHxxWWqeUnHGSdl6zw=; b=E7i/rgfH28nCc+fEOsE7GPhZyqYgvpF+43Ud5oMEJIVc/oHxacO8AH3iNwv6YW714Z qAmFxQUyO7lQ/sKHoKAe/z/OHxxh1WK2ULrklZNXlejEJz1uAszQlori5nLjdXS+kXm5 BIsMw1UQ0G0ZFNcn4SnHv62H2yD5cAbbJWjptFcHBA6kxYmtSneZDWQ0Zy+trtWypoAQ 6MsPs+TeD/WagxV/kwgWOZhEe95/roCAEmWUnBHdry8xO9Op8aEcyhU+Q9xLCOJmw7o/ St+Il3DT4Irw/Tq2Uc/i7bQZorBUzRTg1ppgrmW4s1MXijxqtXb5hl68d58CLUpFWrmr FrZg== 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=/lrMP3yXxmBapUCsKeGNyUtChyHxxWWqeUnHGSdl6zw=; b=r6F6FlKXpmV8lk0QJljKhOn+qN3LdKAC26/P6qpgAAT/AtMAkDcGa22FvfMKEMxxIO bz+3IaWvZwjQcMvHT6U1bc0Fc/EeOQ8zaYBc7foojtmprofn1evorxwtx1lS+dNxVJkh U2aI3s76gD5/iSfPGvD+3zN6cijVzOxS/SVZSdPdfllXAYnAEKoNZCalglJzeGPsP2sA xu4Lkt7vxGzYbJAfVgKA2jl7C/SCJ9d1fjBbM8nlt5bYWhBEVfN45CFgJw4CkOCmUThg JrPhV/AWryHhAt8OT5OG6AH85x9W3XSbqbAQZMZrkGxglOxNIgVQZhqxuCj1yOHIwN1Z nfgg== X-Gm-Message-State: AHYfb5h6cGRF9egIbhUFB2dYZm1QmHDzLMY0p9K4q2DNaNtSY3GjMAH6 bSI36VEv2XDa9s6k X-Received: by 10.28.55.193 with SMTP id e184mr6122217wma.75.1502310696839; Wed, 09 Aug 2017 13:31:36 -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 l43sm5819383wrl.33.2017.08.09.13.31.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Aug 2017 13:31:36 -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 v3 05/12] [media] ddbridge: check pointers before dereferencing Date: Wed, 9 Aug 2017 22:31:21 +0200 Message-Id: <20170809203128.31476-6-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170809203128.31476-1-d.scheller.oss@gmail.com> References: <20170809203128.31476-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 Fixes two warnings reported by smatch: drivers/media/pci/ddbridge/ddbridge-core.c:240 ddb_redirect() warn: variable dereferenced before check 'idev' (see line 238) drivers/media/pci/ddbridge/ddbridge-core.c:240 ddb_redirect() warn: variable dereferenced before check 'pdev' (see line 238) Fixed by moving the existing checks up before accessing members. 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 08440dcb5e6f..12bc8de980b5 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -170,10 +170,10 @@ static int ddb_redirect(u32 i, u32 p) struct ddb *pdev = ddbs[(p >> 4) & 0x3f]; struct ddb_port *port; - if (!idev->has_dma || !pdev->has_dma) - return -EINVAL; if (!idev || !pdev) return -EINVAL; + if (!idev->has_dma || !pdev->has_dma) + return -EINVAL; port = &pdev->port[p & 0x0f]; if (!port->output)