Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96F6DC433EF for ; Mon, 15 Nov 2021 17:42:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82A7C632FD for ; Mon, 15 Nov 2021 17:42:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238759AbhKORp3 (ORCPT ); Mon, 15 Nov 2021 12:45:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:47398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237389AbhKORTe (ORCPT ); Mon, 15 Nov 2021 12:19:34 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E48C63240; Mon, 15 Nov 2021 17:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1636996476; bh=yATXGdaUzZgEZsx70fgb68NdEgPLCYLLlzykAUdNEcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=05y0fTXlEMVSrQrSeNHxrDPy5M7JrKB/iEX7pbC7Zyv7uHch6vwoamJzZQekjWuMU DFFiGqwpQ1Tk5Nxx7BmXrNLXQLPS5ajB3HG6sv6S07atlls591lyjoDah6g5x+niUF FPhEI9XnCi48S4eBM6wOqoDMCthrKRQrYhz/w1Zk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nadezda Lutovinova , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 136/355] media: s5p-mfc: Add checking to s5p_mfc_probe(). Date: Mon, 15 Nov 2021 18:01:00 +0100 Message-Id: <20211115165318.200389921@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211115165313.549179499@linuxfoundation.org> References: <20211115165313.549179499@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nadezda Lutovinova [ Upstream commit cdfaf4752e6915a4b455ad4400133e540e4dc965 ] If of_device_get_match_data() return NULL, then null pointer dereference occurs in s5p_mfc_init_pm(). The patch adds checking if dev->variant is NULL. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Nadezda Lutovinova Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index f8a5ed6bb9d7a..9faecd049002f 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -1284,6 +1284,10 @@ static int s5p_mfc_probe(struct platform_device *pdev) } dev->variant = of_device_get_match_data(&pdev->dev); + if (!dev->variant) { + dev_err(&pdev->dev, "Failed to get device MFC hardware variant information\n"); + return -ENOENT; + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); dev->regs_base = devm_ioremap_resource(&pdev->dev, res); -- 2.33.0