From patchwork Sat Mar 9 07:14:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10845797 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94C721390 for ; Sat, 9 Mar 2019 07:14:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AD9D2FCC1 for ; Sat, 9 Mar 2019 07:14:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 698612FCC3; Sat, 9 Mar 2019 07:14:36 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 0C9AD2FCC1 for ; Sat, 9 Mar 2019 07:14:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725803AbfCIHOf (ORCPT ); Sat, 9 Mar 2019 02:14:35 -0500 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:39392 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbfCIHOd (ORCPT ); Sat, 9 Mar 2019 02:14:33 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id 9E0AFD07 for ; Sat, 9 Mar 2019 07:14:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CgrSVNKLzSli for ; Sat, 9 Mar 2019 01:14:31 -0600 (CST) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id 6A8E1D21 for ; Sat, 9 Mar 2019 01:14:31 -0600 (CST) Received: by mail-io1-f70.google.com with SMTP id m15so17236155ioc.16 for ; Fri, 08 Mar 2019 23:14:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=IrAGSpfys/QRpyQxtm8xVIS+s2k0EJhnsyr/EmBfg3g=; b=Emf9R+hHZkRNSk2YcKYX1LebaWp09A7ghSZBNACFrsTuzuGYZWagpvY8Y/ttTr+Hfk 7z7R1R7ArZa/YbK8Ji8ZX66XUNxHHzfu4n/B6DUWUHxo7u99Wt0NGDhBgZ6kujSsW7tF FRwMMlx3s49nJgUNRwUzoVf7ksDvfu67m6yF4e6wQyqvbW9GOCQTsTlFYL7NnGW/Ju82 WGu/it8KcdSq7S3ydq4Y17+Dk8fF42Fk79A244hh+HB+7+eA7AJSB8XBneiffaXMu2jX QSPwNe55e+CiCr9NiShDGx/pCOaYWzgBeO5nmk1f7C0Gn/k9S5pRZXHO9WJx5SMC1mWC 4W2Q== 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; bh=IrAGSpfys/QRpyQxtm8xVIS+s2k0EJhnsyr/EmBfg3g=; b=RL+ivtpI685V+LVHUWrhykhDBHAoY3mUTmSV0dIGCtxNb/41r11xVYYP3bGSw0lLpA 6G9XsC8NDDJy39xfn9tm+x39+FLfXxAUPx+x2GYMTjqEcJ7XRF/Cgrx/BOshb5t1O15G iLycJfmL1PqxIFfObHPzF/9IP9O0yQkTuLJUe29L2PbwOmTsKl++BTITIEBTZRYHLLtM 97rSfrn22M2ZfDyp4vRHGZ4Iij1NfrGdy3i3ehaXp81xjTG+3tsIA3cJsr45JpebjdV5 k3c+l7ylI2dW1R69fY39G4opW27Ta/cFcBFCcN4Sr919ZXG+/B7Pt0VRMVDbtfGZcYTK qRCw== X-Gm-Message-State: APjAAAX43f7XBrVgMV2UlzcP0gZN772d51CgQcy4Xna0GE3HzwLUjDPO 4zwV2OuB3Jq/fPKbuEUcNjvBOOfPtrwiMOfarRCzLrcZ0Dz4rnkuspa4Ot1Ttt2zbIZu6jbPaHk DIzUB+RxrecpE/6hae3Mdm7pSEi+sf+4nG4I= X-Received: by 2002:a02:47:: with SMTP id 68mr13019158jaa.121.1552115670973; Fri, 08 Mar 2019 23:14:30 -0800 (PST) X-Google-Smtp-Source: APXvYqxFz+Wa8QqySDaPF5/FMuaIn/65zGb6HXAHEp5gqDbcprybYPSh+TFVbDgF89iBafKOvqnOJQ== X-Received: by 2002:a02:47:: with SMTP id 68mr13019154jaa.121.1552115670748; Fri, 08 Mar 2019 23:14:30 -0800 (PST) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id v8sm3886449iop.42.2019.03.08.23.14.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 23:14:30 -0800 (PST) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Jacopo Mondi , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: renesas-ceu: fix a potential NULL pointer dereference Date: Sat, 9 Mar 2019 01:14:24 -0600 Message-Id: <20190309071424.3600-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of_match_device cannot find a match, the check returns -EINVAL to avoid a potential NULL pointer dereference Signed-off-by: Kangjie Lu --- drivers/media/platform/renesas-ceu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c index 150196f7cf96..4aa807c0b6c7 100644 --- a/drivers/media/platform/renesas-ceu.c +++ b/drivers/media/platform/renesas-ceu.c @@ -1682,7 +1682,10 @@ static int ceu_probe(struct platform_device *pdev) if (IS_ENABLED(CONFIG_OF) && dev->of_node) { ceu_data = of_match_device(ceu_of_match, dev)->data; - num_subdevs = ceu_parse_dt(ceudev); + if (unlikely(!ceu_data)) + num_subdevs = -EINVAL; + else + num_subdevs = ceu_parse_dt(ceudev); } else if (dev->platform_data) { /* Assume SH4 if booting with platform data. */ ceu_data = &ceu_data_sh4;