From patchwork Sat Mar 23 02:44:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10866733 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0904A1669 for ; Sat, 23 Mar 2019 02:44:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4CB12A861 for ; Sat, 23 Mar 2019 02:44:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7F8F2A864; Sat, 23 Mar 2019 02:44:53 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C1712A861 for ; Sat, 23 Mar 2019 02:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728311AbfCWCoo (ORCPT ); Fri, 22 Mar 2019 22:44:44 -0400 Received: from mta-p6.oit.umn.edu ([134.84.196.206]:51952 "EHLO mta-p6.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728293AbfCWCoo (ORCPT ); Fri, 22 Mar 2019 22:44:44 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id 9E798CC8 for ; Sat, 23 Mar 2019 02:44:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 57HtEIhZszNa for ; Fri, 22 Mar 2019 21:44:42 -0500 (CDT) 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-p6.oit.umn.edu (Postfix) with ESMTPS id 6181DC4A for ; Fri, 22 Mar 2019 21:44:42 -0500 (CDT) Received: by mail-it1-f197.google.com with SMTP id e63so3979447ita.1 for ; Fri, 22 Mar 2019 19:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=DQEP0Ecrj0S52jv+NCt0UhJGFEyXuw7IK/qEbjIGKCA=; b=d+18mWO2B9ynaSObnkOK348G3yJwtpJzIT+LdvYHjaG14R1RVHK39GtyeS6WL+wfnK zlqTD+/H6kFbooUhJ4GFCUTZ1SpavlosxSbgHYu6ckH23LL/aLsIECdlIWPxBQ7XpCrc IvvQdTuROozAM31W7BeCIPO4RmvB8pYTDNgVX/hrnCNNSTngDJ+gYYAYTTdoh9ALfy44 bUcq0A/W8OYn8LbZdR7+kfRhDQWpPyc1Y2FSTnuAuwmTVHwQhbv6x/GR64D149OyGIjo t+piT+jtsLuj6tBTT43hHws1K8G1zWsfAXXIstfKHh4kKvL6mpAoUsLGsSBQbkSd6Hob ZAVg== 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=DQEP0Ecrj0S52jv+NCt0UhJGFEyXuw7IK/qEbjIGKCA=; b=LiX4busMbvzlDz4AR+vJBQFuM/hHBGddlMMMn8Zjms3ss5of5JCgH0KzaF/zbBbQf2 R/zRlOTKkYXnnSuCLBfJvXmuRpCZhXlwKcEJRiY61oMHGZkZqvWGNCdQ1oxuG0hqo5Am hHR2U9/ba3rsDciAivi+3f3N78RUhtkr7qYRhjBW2toXJtXRfQWQkDisPq48DvgdILwC 9t/sYqlDVKyYO3d4eEHQMg/MkdeE1VD7O+G4nbGrcocJfQerKFic90Q7YqHIUZDk13EP cH6hSBlPUZvNJi1UtWZU32PCUavjLrp0eGa845Fn98+gXzODLFjwvAsD/CWRAL0yWD81 a+4w== X-Gm-Message-State: APjAAAUFyB98jouFHmXMV25VeuHJ2dGj4YfALDkR8iA4cxxsFjDpFfry 7h+YdJTRe65sjC9Sr6Z6ysSa2m2BL9c5EoO7AvjE3L9decY8HTgfjoHtLhjgpZXE5Lg7o3MN+8f l0tnZRqN/0Ks4ReFztERPfp6Y4Qs= X-Received: by 2002:a6b:ee02:: with SMTP id i2mr8847655ioh.219.1553309082040; Fri, 22 Mar 2019 19:44:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrvV0mJ8xglWbZ7EKdV7CId3I3/GAxOiBwjb6juiO3+riV7jk8ZC6UbtVdNc2EpOR6UdGkow== X-Received: by 2002:a6b:ee02:: with SMTP id i2mr8847649ioh.219.1553309081825; Fri, 22 Mar 2019 19:44:41 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id j23sm4120997iog.59.2019.03.22.19.44.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 19:44:41 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] input: pm8xxx-vibrator: fix a potential NULL pointer dereference Date: Fri, 22 Mar 2019 21:44:33 -0500 Message-Id: <20190323024434.14794-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of_device_get_match_data fails to find the matched data, returns -ENODEV Signed-off-by: Kangjie Lu --- drivers/input/misc/pm8xxx-vibrator.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c index 7dd1c1fbe42a..740e59c11808 100644 --- a/drivers/input/misc/pm8xxx-vibrator.c +++ b/drivers/input/misc/pm8xxx-vibrator.c @@ -196,6 +196,8 @@ static int pm8xxx_vib_probe(struct platform_device *pdev) vib->vib_input_dev = input_dev; regs = of_device_get_match_data(&pdev->dev); + if (unlikely(!regs)) + return -ENODEV; /* operate in manual mode */ error = regmap_read(vib->regmap, regs->drv_addr, &val);