Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp6555011imb; Fri, 8 Mar 2019 23:06:16 -0800 (PST) X-Google-Smtp-Source: APXvYqzvFHMrzsYdyx3WimJt5clJU0GBUe2Y9v4fryO0uYYQA7qM925L+XhbN7oDED7uiLqNEVoF X-Received: by 2002:aa7:90c1:: with SMTP id k1mr22252961pfk.202.1552115176252; Fri, 08 Mar 2019 23:06:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552115176; cv=none; d=google.com; s=arc-20160816; b=ssRl76dDqZ94jpzdXR4CrPLk5M6i+aicyEaKkCTBXKl6PdC0un59pSZvBJIv4ocXcF HyqUjvvVfYa0hazP5MIyxFnVPGUqMzw6FrO8Lfp3AQm1qO2/2hU5MA+u94m1kr31UTEO nNEvqra2EBCZgBE1BaQXI7z5mUC2UitKdv+H5cmd8DBd1iNBm4bL4KhkSzu5ZBrAOaWM ltNLBU3064/0vcItfDCIbbKaBG8dudTrM7taxGGJ+9vW42hHEy2GIbcdfXoHPo/VpYCU Gw07OVzHkERyLUW39WcHCvSz9xDc0s+iL+4iraOKz4VJuz5/9KPoAoasCiLVUCMv5kfU 38LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=j2BKY+t1WAx9ChzDFZSzJABdJ0WWzcfwEgCZ2b2oFVg=; b=x6ZaaAoNJYuEV2X2qluYgCQwoSkb/5fUIYbnkZFLS3EW6mYYwblv9k19sjIWbx0hN8 Ev3iL3kFgQ2qeMoXlAsT2o3CaOiEOkrwXW7NYftchyLDprgmP3PE/seX0Lh6AI2KPBea y4m9+APe5rruzer9leGLhy4/PnBMjTreD13y82NRaKaLyHVWYQzk7+Jr/n57org9p6mG HRyJ7p4f4afbkn3PJpJQL52YSxQKiMbWmQkmTMmy/ncEl08b7PlWkb0Iu4k465pSyXj8 /u/DGCcjMlYSBy/FkY+F2acV/ZttjKOlJV212Tji/XIdfQ9xNiaJnS48g7T1DFkPiAWx fvLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b=fZIlvJG+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si8975262pld.183.2019.03.08.23.05.57; Fri, 08 Mar 2019 23:06:16 -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=@umn.edu header.s=google header.b=fZIlvJG+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726625AbfCIHFh (ORCPT + 99 others); Sat, 9 Mar 2019 02:05:37 -0500 Received: from mta-p8.oit.umn.edu ([134.84.196.208]:44902 "EHLO mta-p8.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726262AbfCIHFg (ORCPT ); Sat, 9 Mar 2019 02:05:36 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-p8.oit.umn.edu (Postfix) with ESMTP id 217C3C5D for ; Sat, 9 Mar 2019 07:05:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p8.oit.umn.edu ([127.0.0.1]) by localhost (mta-p8.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5WXbqEr6s5_l for ; Sat, 9 Mar 2019 01:05:35 -0600 (CST) Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p8.oit.umn.edu (Postfix) with ESMTPS id E3489A11 for ; Sat, 9 Mar 2019 01:05:34 -0600 (CST) Received: by mail-it1-f197.google.com with SMTP id x9so13775289ite.1 for ; Fri, 08 Mar 2019 23:05:34 -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=j2BKY+t1WAx9ChzDFZSzJABdJ0WWzcfwEgCZ2b2oFVg=; b=fZIlvJG+uDNfwDB+zAhg423IF86ug76/U9+M72573kaXtQO+JkKp98AEL0YIUuPaFy SahkL2dXOfvvk+71b8gF1/RzUpbzsyYe9yfvehYAQ4MHr2WSeHzdsNQdz06zx7yXnWcm JTBOXlcuo8iD3Vv51g1xgNIu83O0pY+UZBnXi5FYf1u3R4cEtlhVtHnO8u1qXhxcgtgp LZd7zaEtcSmFfUCEHS5G5RotHrOqCZEPoRQ5BVK6iH9jEuECuJNqbq+nFjI72As9DMge JlYjYGBv7b7n1iEyFu9OYY+9ZCAIlZtOQh9ktV35IjCAdTrH2ccnuT8+xbeh/9G2K4OZ hAMw== 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=j2BKY+t1WAx9ChzDFZSzJABdJ0WWzcfwEgCZ2b2oFVg=; b=fzBmB97q5xa5Iht8y4zI5ve0cGSWWVqqKW9ScCzXKf9eDpt6ZwYUH32zrdoSe1yVCj 7BO2c69gDpPrEnLLUVUWt2bCLMu3IDpSpeKuTy/albgaf1SbRw8fH3WD1ftEqJrU9Ubr 1Ionem5LAZAiK3Qo1AgRRiH+0pD9taajWHd3S5ZPxHKcKQMA12AF0vq6isAQH7BsN8Ma CZ2cN0ZBhGys4w9kCtwI2hyts3NBymGrPeM5TkD7wSuAdRi0iu8TjnR8Yf5KjgCuLiRJ 6v8fu+qadacZm/rfQYAwjZrY3bB01hJL0L+lWZJCfJOuC6sKBVr8KW9wcClRtPxMRHVF +mxA== X-Gm-Message-State: APjAAAVq1aLxm52IX1etEx0ADzEHH/Obo1uzsQ3Tl3PjHtQeS2TuGuI0 sEcmrjNsin4AzQ2nRGDL+VlkKAyx1PxKCzXhRDd6wPDCxrwLm4nG51yVp4cCQHybcCMWAxZtp+4 H8cJGxeg7rbWTtP0Q3gMBvllIqvdq X-Received: by 2002:a5e:c249:: with SMTP id w9mr1297611iop.284.1552115134428; Fri, 08 Mar 2019 23:05:34 -0800 (PST) X-Received: by 2002:a5e:c249:: with SMTP id w9mr1297596iop.284.1552115134176; Fri, 08 Mar 2019 23:05:34 -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 z24sm3977671ioh.57.2019.03.08.23.05.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 23:05:33 -0800 (PST) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: rcar-vin: fix a potential NULL pointer dereference Date: Sat, 9 Mar 2019 01:05:27 -0600 Message-Id: <20190309070527.2657-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; strscpy(mdev->driver_name, KBUILD_MODNAME, sizeof(mdev->driver_name)); strscpy(mdev->model, match->compatible, sizeof(mdev->model)); -- 2.17.1