Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp6668035imb; Sat, 9 Mar 2019 03:03:00 -0800 (PST) X-Google-Smtp-Source: APXvYqz3qtWcwwP/ZGpG9QQmL4uTmgQKeL8O67JwieMqRLuNpjDNK9lP1X/lnzUeESBX5cwgYtu7 X-Received: by 2002:a63:ec48:: with SMTP id r8mr21147506pgj.50.1552129380026; Sat, 09 Mar 2019 03:03:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552129380; cv=none; d=google.com; s=arc-20160816; b=d5n7qgfnJF+T7GzuI8zKeP/Yww3l36R06asLzzFc6zxSGYloXHbf0xkNEDWxaJHh3N 0OPQQ154DtPdsIqOC/EF/BbGrk3xTyS2DCQG/ZIbl26xijtIH0CpnDEvTH63wcolnMV5 Yn6ICjQeWTmERlt1xxY/ZjpjRCqxrDaZ+vwX0ZJ30nD8MS4bWGfUF+KBQKwS6/H1FLN9 /PsWb6xDSM4NVmp+BpHTf3qaeSLWxgDWAEPSnHMsifXNeHClxxtR1qd9Y7L+26MUjBse iKZBEX/YHyHe6SnIxaimpa2VoILMHHtgwQVuJABmQ3d69Fp3y+rC3+1sZGTtYfQzgHlr ZhdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=q7EgyTKkBwCKENlJl+P4FiMkN5L+S2Lq9VbdUR33+dI=; b=qWnf2p2eXrnxT7jF3vbFBreQf01H17VAWdXG1ibxs51RTGe4jV1WS3loOrU4Epqjay MhFa6YeoOTSq8aFfEe/+CQexe2ISY5ZMROHVhojuJYYMcreORJ3HKbpN551o+wo9JVdX Hz/DHVDSwmXLXiTnIjimrT0wn4A7GvwBa6jrrq2XRJx8T6XwYHHlONm1q29nyStYbGHd HQIP/g0hnfl0JGq5pQwgnpX0/H16KLbgEIrj+Hgmd6FWfWPPit+5p5p/oYOnuOZEvitJ r4BzNMjfkvGwkvK2DZbrvTVapVKO3Wq+0AFFPp/8yxV4MYfQ1CgBM3knr1OMPAO8Iuy/ i0tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ragnatech-se.20150623.gappssmtp.com header.s=20150623 header.b=PM96cNat; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si240910plr.354.2019.03.09.03.02.41; Sat, 09 Mar 2019 03:03:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ragnatech-se.20150623.gappssmtp.com header.s=20150623 header.b=PM96cNat; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726399AbfCILCV (ORCPT + 99 others); Sat, 9 Mar 2019 06:02:21 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:45055 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726235AbfCILCV (ORCPT ); Sat, 9 Mar 2019 06:02:21 -0500 Received: by mail-lj1-f195.google.com with SMTP id q128so123286ljb.11 for ; Sat, 09 Mar 2019 03:02:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=q7EgyTKkBwCKENlJl+P4FiMkN5L+S2Lq9VbdUR33+dI=; b=PM96cNatutYRGN+iq2u2T2qoRxxFuuER0zpWwSJkvqLaqkSGThHEpAJUuWllBn32UE GmRqoXL86HU3mm+d3rFjVzQmqSFrtvEXn4ijiDMpXXYlU4AJ8PgaCrssqGmhH0mhAjxT Q8eRYVYSP9u5jKrYQei76kYCudXNgPCmGE005d47QHvd70YAoGR7ZvsaQ+6i/ehGey0Y hEjlB5n1O7dZ3f9rPeEATxlgHhuy/6oPQpzWoTBCIcryzUUIvf3tSiHLmq9lrp5yxXBo NFoFxiR486MiWEtHdJ1UPn9rHeEVk5fh2yh783wvy73H39kcmHfY9CBleE+NS7Y35D9r ArPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=q7EgyTKkBwCKENlJl+P4FiMkN5L+S2Lq9VbdUR33+dI=; b=oK8mpbQBz82KHghaJkmYWGVB4w22gS76cr9H+6Q8h5juzSsDZvcuXTH/ssyHBCKYHT 0BYBAVCIC4+PfCJoknrQg1jMIZe5WAbDzrOWvvvxyCWSy9TWIXvxVqpb1nqx9a+n82E0 jyU6S/5lbiTO5Efxu7ikgLGfIeeRGF5U/gEwBH4opXWqaVcT6+O3xlg4xHkYzZ1y0PUi Hw+D2ZZ6JCoYRHM0fMEjC6660aGJSkgaMFHVSUQni9JdOB2pjEx6kKCbxzW++zxzuoLe WXVZA9dckAIquytH2oN3fVnvo6uEvHM3wQDgpqW2eHVtTlhV5p1Dqiz0RW7WwkMbAyky 8ozA== X-Gm-Message-State: APjAAAURE480EQqgNHakX64cAPrdJUAs4xxeBgHvmS8oKpPN+KSlCCSV LYrG7/78moQO7DlG5u0NjCk1Sg== X-Received: by 2002:a2e:5d88:: with SMTP id v8mr11484224lje.150.1552129338883; Sat, 09 Mar 2019 03:02:18 -0800 (PST) Received: from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99]) by smtp.gmail.com with ESMTPSA id q2sm36232ljq.19.2019.03.09.03.02.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Mar 2019 03:02:18 -0800 (PST) Date: Sat, 9 Mar 2019 12:02:17 +0100 From: Niklas =?iso-8859-1?Q?S=F6derlund?= To: Kangjie Lu Cc: pakki001@umn.edu, Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] media: rcar-vin: fix a potential NULL pointer dereference Message-ID: <20190309110217.GA5281@bigcity.dyn.berto.se> References: <20190309070527.2657-1-kjlu@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190309070527.2657-1-kjlu@umn.edu> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kangjie, Thanks for your patch. On 2019-03-09 01:05:27 -0600, Kangjie Lu wrote: > In case of_match_node cannot find a match, the fix returns > -EINVAL to avoid NULL pointer dereference. > > Signed-off-by: Kangjie Lu > --- > drivers/media/platform/rcar-vin/rcar-core.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c > index f0719ce24b97..a058e2023ca8 100644 > --- a/drivers/media/platform/rcar-vin/rcar-core.c > +++ b/drivers/media/platform/rcar-vin/rcar-core.c > @@ -266,6 +266,8 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin) > > match = of_match_node(vin->dev->driver->of_match_table, > vin->dev->of_node); > + if (unlikely(!match)) > + return -EINVAL; I don't think this is needed. The driver depends on selects OF and if we get this far we it is because we had a match already. The reason to call of_match_node() here is simply to retrieve which of the possible compatible strings was matched. Am I missing something? What scenario do you see where this can fail? > > strscpy(mdev->driver_name, KBUILD_MODNAME, sizeof(mdev->driver_name)); > strscpy(mdev->model, match->compatible, sizeof(mdev->model)); > -- > 2.17.1 > -- Regards, Niklas S?derlund