From patchwork Sat Mar 9 05:39:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10845781 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 984921390 for ; Sat, 9 Mar 2019 05:41:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 812282F096 for ; Sat, 9 Mar 2019 05:41:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7548F2F182; Sat, 9 Mar 2019 05:41:23 +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 205D92F096 for ; Sat, 9 Mar 2019 05:41:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725536AbfCIFjq (ORCPT ); Sat, 9 Mar 2019 00:39:46 -0500 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:52406 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725681AbfCIFjn (ORCPT ); Sat, 9 Mar 2019 00:39:43 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id 53A9FD43 for ; Sat, 9 Mar 2019 05:39:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S2IZpw0lTHae for ; Fri, 8 Mar 2019 23:39:42 -0600 (CST) Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id 1EF6FD3F for ; Fri, 8 Mar 2019 23:39:42 -0600 (CST) Received: by mail-it1-f200.google.com with SMTP id v12so13906845itv.9 for ; Fri, 08 Mar 2019 21:39:42 -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=DQEP0Ecrj0S52jv+NCt0UhJGFEyXuw7IK/qEbjIGKCA=; b=oD4V7bnmUpUERlGamgt01MtaUmezofUy+swDi3wcOj+jFzoM3HqY+n0JhreC3OU7td ZEIZX3sCs8QIwhKZedWitdJUKHJImX5FvVghEPzDYjYXqj8dBzUEguxbs+Nrrxv8hmc0 /Fo/imU0P0e8FfKBdvGQ2FI18a1uvGb4qxkOW2e2YkAIVvvkcMAWLowzUVShokpkucg8 WrX5FYMzsf69lCVRYSIwb9ZK974xZ995PDYnAy2tayQMZw28dJESN7uKndXLNXUZcSMz z8y8pgDOBoCM+HjTG3GaD9anZ3zxkh+G6nmKRV21x4ITVAYtKJJiksKnVZGgoWOaVrom vvng== 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=Tp+LmtCKZrp6ix0IuTtVPmf4bMqCiUpD7HuAi808SicY8l9A+uOr2uHQvEi/AVYCxh hWFgXNfBNLb49TfQH0rSi20cFiZqCCquPGdGhHAgmRk0GoLpiHBZahIYXtRb9F/6l21u LuEqfG6ODsl99lhgHw7sizhwHEQTm3mrHRf0xNMUuHQc4B68L+APVH6LbljKE2zC+ACt P/rOugZedVo80/Go7jda5c6jn9x/d/F3jSD4kFgpnhfu7TSN9FMS17cOUe89BsyMx9lv gD2rv3cD/qHEt89LesIBJUkteBfKT5jvE+/QxaE5nvI3YNGRy6URxJdTW3+B2GG6GGYi LmmQ== X-Gm-Message-State: APjAAAXwwP0IjEJmcSNXdpOzF6QQdPD1NXr/PsTN4i1myaN+Kp+GKvoG MbWZIqTw//0wUKOHCSd/Y4M6ruJRtqNRDGnxQKtzTUq7qACmdA1SOwqVgYiOsMAKe5iFEgjE58Z jnnzGpmeMqmXgaVpZEBrW0uh0Pn0= X-Received: by 2002:a5e:8c0b:: with SMTP id n11mr4156686ioj.265.1552109981464; Fri, 08 Mar 2019 21:39:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyckxRdIscGyNkbAWu6qHOffxv446t+588Mk+zAZ1TO1WHTZx7FQ2Cj4gqJl5vNxgxJv1o/Tg== X-Received: by 2002:a5e:8c0b:: with SMTP id n11mr4156681ioj.265.1552109981239; Fri, 08 Mar 2019 21:39:41 -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 b20sm4063706ioj.12.2019.03.08.21.39.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 21:39:40 -0800 (PST) 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, 8 Mar 2019 23:39:21 -0600 Message-Id: <20190309053922.22212-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);