From patchwork Thu Nov 12 07:42:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7600371 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 37F4A9F392 for ; Thu, 12 Nov 2015 07:45:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61B6820809 for ; Thu, 12 Nov 2015 07:45:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9EF0820804 for ; Thu, 12 Nov 2015 07:45:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwmWy-0006CQ-JL; Thu, 12 Nov 2015 07:42:52 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwmWv-0006AN-0J for linux-arm-kernel@lists.infradead.org; Thu, 12 Nov 2015 07:42:49 +0000 Received: by wmec201 with SMTP id c201so19149438wme.0 for ; Wed, 11 Nov 2015 23:42:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=/TQick1aZenRyaNi7k4RDOBR4NeXsCPLwvHY0zfAvL0=; b=AdYB3yZs/slNQDfEzVwTi2bTweJiFGTvIoWQvxEtADu0iRFRXXMjwvCLuisQ3AvxIk HM7HJYGZvtMGchMID+KnE8ZklauICJH6ZRy8n5PZg5tfNg3RS/TGzm40rovcFRWsXrsA 8av+b/hJYfP07sRbbmWeuu4seOqwW8alSvL2tRcitKBSrXpdeqNz8WqogGiLAwdblNXE bJYdqE0b4He4ZTlGn0DMV7bih6A2oCwNCd2XMx9/XRSbcgSOu0sRVE2TIbe4NQLbZHJ2 P385BvyDCslynB7yWG1y7lYa99HqA2DuIdqQ8OzW0T6WWlj9zBlGyCDwmO508MEDJNy8 U7CQ== X-Received: by 10.194.186.238 with SMTP id fn14mr16015961wjc.128.1447314147219; Wed, 11 Nov 2015 23:42:27 -0800 (PST) Received: from Red.local (ANice-651-1-284-125.w83-201.abo.wanadoo.fr. [83.201.64.125]) by smtp.googlemail.com with ESMTPSA id hu2sm12948824wjb.21.2015.11.11.23.42.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Nov 2015 23:42:26 -0800 (PST) From: LABBE Corentin To: linux-arm-kernel@lists.infradead.org, maxime.ripard@free-electrons.com, thierry.reding@gmail.com, wens@csie.org Subject: [PATCH] pwm: sun4i: fix a possible NULL dereference Date: Thu, 12 Nov 2015 08:42:12 +0100 Message-Id: <1447314132-29458-1-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.4.10 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151111_234249_266042_6E6CE773 X-CRM114-Status: UNSURE ( 9.80 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, LABBE Corentin , linux-kernel@vger.kernel.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-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP of_match_device could return NULL, and so cause a NULL pointer dereference later. Reported-by: coverity (CID 1324139) Signed-off-by: LABBE Corentin --- drivers/pwm/pwm-sun4i.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index cd9dde5..3011fcc 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -291,6 +291,8 @@ static int sun4i_pwm_probe(struct platform_device *pdev) const struct of_device_id *match; match = of_match_device(sun4i_pwm_dt_ids, &pdev->dev); + if (!match) + return -ENODEV; pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL); if (!pwm)