From patchwork Sun Dec 28 18:12:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aniroop Mathur X-Patchwork-Id: 5545741 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 84204BF6C3 for ; Sun, 28 Dec 2014 18:12:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC18B2015A for ; Sun, 28 Dec 2014 18:12:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86F282012B for ; Sun, 28 Dec 2014 18:12:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751752AbaL1SMH (ORCPT ); Sun, 28 Dec 2014 13:12:07 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:54853 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751733AbaL1SMH (ORCPT ); Sun, 28 Dec 2014 13:12:07 -0500 Received: by mail-pd0-f169.google.com with SMTP id z10so15890815pdj.0 for ; Sun, 28 Dec 2014 10:12:05 -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=cNNFd+LWVGDaSdRJgOJ46uY+iZYmDwuvpZWe/9D3DDg=; b=cDf7/WOUbqhKTHtt1IUmf+kwLFmREE4TRKuawtC0ObR1UeibPyBymk3+1f/wLy6MfU s61ndNgN2fqLugv2w5kc6Cr15AU2GZRTA/nIBrgG2hvi0EJ+KQERpKpAlTOG9TDYU3Mp nmHnO2RSrJTvL99Y83txlt9/dXS9d+rSoCSd3L+uobZs0Ex6iYgjizaoDL79ZKB8GX6T tKv1bAWin9sRMMeU/eA8Ce2lfGM7OJtuJ8zzjmU+LiPW3jJQu8l/H1QMrPsgALA6mt0f 5fXrCTdR+r24gKePw1EB3Gyy0Itc/vQ2IhjUytD1QfKBUTKDFJVCRs4ubXGz+9aKpt4v tEjQ== X-Received: by 10.66.221.168 with SMTP id qf8mr84786572pac.102.1419790325581; Sun, 28 Dec 2014 10:12:05 -0800 (PST) Received: from localhost.localdomain ([115.118.72.223]) by mx.google.com with ESMTPSA id hj2sm33448857pbc.69.2014.12.28.10.12.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Dec 2014 10:12:04 -0800 (PST) From: Aniroop Mathur To: , , Cc: , Subject: [PATCH] Input: Avoid kernel panic during device unregistration Date: Sun, 28 Dec 2014 23:42:05 +0530 Message-Id: <1419790325-4004-1-git-send-email-aniroop.mathur@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 This patch adds null check before actually unregistering the input device to avoid null pointer exception which leads to kernel panic. So now, input device drivers won't have to worry about or add null case condition before calling input_unregister_device() in shutdown and remove functions. Signed-off-by: Aniroop Mathur --- drivers/input/input.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/input.c b/drivers/input/input.c index 01fe49e..575219d 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -2170,6 +2170,9 @@ EXPORT_SYMBOL(input_register_device); */ void input_unregister_device(struct input_dev *dev) { + if (!dev) + return; + if (dev->devres_managed) { WARN_ON(devres_destroy(dev->dev.parent, devm_input_device_unregister,