From patchwork Thu Feb 1 11:00:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10195287 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 C87AE601A0 for ; Thu, 1 Feb 2018 11:01:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1A8A2846D for ; Thu, 1 Feb 2018 11:01:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95E402888D; Thu, 1 Feb 2018 11:01:14 +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=1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED, RCVD_IN_SBL_CSS,RCVD_IN_SORBS_WEB autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3BC6E2846D for ; Thu, 1 Feb 2018 11:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=rsLBieQwBa8Ot1rKpd4EZ5a6dzSE1jrl90SmkpaV6qs=; b=jBq lgb6AXIkivqGgeR0WPuz6SI2kXvR8DC6G+1CKcCp0FVzMyUHNkTSKA+z0bKhRdmobVf/Yeyy3Cp4k PzudrQ5aIr7EKgB5O+G41uabTkcVS9s283pJf/N9qNq1jOes/qVK2RPyahBma4LJKITQh3blct/Si kYEcQTiJ+QnB0NO4Na9U1LNCo65G3NjOzkMl0f9oipf1pRXAxNciYr4TdDvvkZIdYkBA977v9QhN5 uDBJqfUM+FE7YDd1LvrZkHuc7WKxMbQD8hYcpgJmflrjXCxjeGafPIsKtufgvAbxzwgehuHaX1k8V EuJZeTOGN+s4yxMoihROvm1ZRcHIzbQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ehCcA-0003Si-Dw; Thu, 01 Feb 2018 11:01:10 +0000 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ehCc2-0003RZ-Ia; Thu, 01 Feb 2018 11:01:08 +0000 Received: by mail-pl0-x242.google.com with SMTP id f4so3215507plr.10; Thu, 01 Feb 2018 03:00:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=aMbY/pJm1HQbCCt6VRr4NV9q2OTJ+dD1JaYqMJyKyTs=; b=mjbBZERELFilnJZEzBpPHfpn1syQWUD2Syl5pepLYDWvgCbFkXXyq9Dp4OGNuLmUQ0 YUhGBoo0DA6hA6fafQT42U9pLozQTdR1qZOC9iK0K1IOgClNOGanp1D+HKKoHrJpmAAR UFy8BDXwO5J1VsEEQHxF+NcIkrDuoHY6g5dwYKLD3fEOHbWjfoR/0C7/kzRAlS4jtvzV n+FDbzQQy8jAcf9HMJSvjRFD4xRrCF9jNZCNvKBHqCi6UD+eGTALPhoNvuDkypF9jbdZ P39BNvQk/sp7FvRl7/0WV5e71uoQYfokZRe76HCUSKWOUG870Gbi0z4rgH/9ZKru7o77 MYHw== 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=aMbY/pJm1HQbCCt6VRr4NV9q2OTJ+dD1JaYqMJyKyTs=; b=TGlW0pEzrNXyd9vl577//27pqQ5Rgg6ItnhTFxpOIjZxWyy5NCv5GYQKoN5HuYshQA 9DUEA6w5bqXeC4m8kq8CHw6FBiv3leNdrR4fmZhuOEOJs6pnvzJOaZ/6eakQJwntvHrr YtimG+JMiyHI64vLaz1yMFwn1jctqIlbeAd7FexOhNBTHZntLoPPxawBSwhaxOBEwvgd s7exnsSSSWkH/O9Ce0Zf0MN9Vl3QMuErVYt6mxnQsGDK/qMWx5r80GeQuqlM9b0s+iVS CWW6pN0Z42+O3xGZR1I5ZFcdEIBwYUwBO4KFLK5LTEtk3tWDCH6+tO9wdbCGW2Y/p56Y JI6w== X-Gm-Message-State: AKwxytdVkpuOTzTVC8uaaNRgI7kpr9/AfH7nFT9LavacRT4xje8OWXjd Yd+JxxNi+wbyZfhmt7NBW3c= X-Google-Smtp-Source: AH8x2254hnUBhB4NH/HMGPnnRlb3YMnpH/a3JBypU5Q7fso9SQhAySr1/fDpkpw6p5UHxsXKbe+1oQ== X-Received: by 2002:a17:902:7716:: with SMTP id n22-v6mr31704093pll.388.1517482850967; Thu, 01 Feb 2018 03:00:50 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id 14sm29322343pga.12.2018.02.01.03.00.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Feb 2018 03:00:49 -0800 (PST) From: Himanshu Jha To: matthias.bgg@gmail.com Subject: [PATCH] soc: mediatek: Handle return of of_match_device function Date: Thu, 1 Feb 2018 16:30:22 +0530 Message-Id: <1517482822-28758-1-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org, weiyi.lu@mediatek.com, geert+renesas@glider.be, sean.wang@mediatek.com, linux-kernel@vger.kernel.org, kevin-cw.chen@mediatek.com, mars.cheng@mediatek.com, Himanshu Jha , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In scpsys_probe function, return value of of_match_device function which returns null is dereferenced without checking. Therefore, add a check for potential null dereference. Detected by CoverityScan, CID#1424087 "Dereference null return value" Fixes: commit 53fddb1a66dd ("soc: mediatek: reduce code duplication of scpsys_probe across all SoCs") Signed-off-by: Himanshu Jha --- drivers/soc/mediatek/mtk-scpsys.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index 435ce5e..6e7f196 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -981,6 +981,9 @@ static int scpsys_probe(struct platform_device *pdev) int i, ret; match = of_match_device(of_scpsys_match_tbl, &pdev->dev); + if (!match) + return -EINVAL; + soc = (const struct scp_soc_data *)match->data; scp = init_scp(pdev, soc->domains, soc->num_domains, &soc->regs,