From patchwork Sun Jul 23 18:16:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9858525 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 99152600F5 for ; Sun, 23 Jul 2017 18:17:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 934F228550 for ; Sun, 23 Jul 2017 18:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8685D2855A; Sun, 23 Jul 2017 18:17:35 +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 D5B362854A for ; Sun, 23 Jul 2017 18:17:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751524AbdGWSQt (ORCPT ); Sun, 23 Jul 2017 14:16:49 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:36707 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751458AbdGWSQm (ORCPT ); Sun, 23 Jul 2017 14:16:42 -0400 Received: by mail-wr0-f196.google.com with SMTP id y67so15036919wrb.3 for ; Sun, 23 Jul 2017 11:16:42 -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=N0aI1vnW+DmvDB8WCgG1GnVd9FzOIm8N/E5KVs6iDv0=; b=SUvFNf7TA2av1OtnCxDQohqm3zR+yrxKQe4xTBTQFytD168E1VHjQDu/7NplaaUYDF fecNFOhi2LFzYJlNoK0MrltbF3N+tQnDVOD73jhFDG5cyiQItUL/Mv6ura9pYsZR3P1n KvHjZoemxE3p/KttLeo6vGL0RAvGQm7hFVB/ZsLYLpjkf1ST854EF/Xbvk7SfEC/iIXo mGxqas71n7smeK+jKcvXkC2tj2o6vWOQWwIXpNPCD1WwQek+azGfFTxSB6MfMWGlAoF/ yzj/SLY6hKxyp4hPD9qD8XkJ+p3BZmNNlQTpp0CtB/1so4o1Yzx6xiD7zfcHsSRyKarR 7baw== 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=N0aI1vnW+DmvDB8WCgG1GnVd9FzOIm8N/E5KVs6iDv0=; b=a8s5E8nzGO0mQz/x2LAeoOIwApnlcYm+LLgVGiZ/4po9rJKvO54x7aHS0CLYy9V5xv zni3qyna1Snv7X19HBJZuuLfDuM1PbsHNN+uKH+D3mOYvO5N4mMZmNuHiupNQarHqSuC FFSrSrGHyVdu1VWfZM/zLAr3+llbZ/XhSl0DYj6XOAzSh2+IssygQpIfQ23LEwLG7Uwr r4G8csCs3Gv403fSR7mbST/g0AFiDJVA0CPzAzvBD+g54AbyQvF+iXDV3O3D2zjPGtAt NC/XWFT0cyYON/mE2+8Kcht4+VSCyWQj5qOgO7Is8cjG/GTVKmt+/zsDftjwa17k0ned FDuQ== X-Gm-Message-State: AIVw112RNjfvkQLgqD3JJzRZZ6cS60NEgH0ZeqR7KG4g1Fcnc1LWWiJs WBGmrGWe6zXgUJXV X-Received: by 10.223.168.15 with SMTP id l15mr15743014wrc.37.1500833801588; Sun, 23 Jul 2017 11:16:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Jul 2017 11:16:40 -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 07/14] [media] ddbridge: check pointers before dereferencing Date: Sun, 23 Jul 2017 20:16:23 +0200 Message-Id: <20170723181630.19526-8-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 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 374d095565dc..72f4cd3de2b8 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -169,10 +169,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)