From patchwork Tue Apr 12 06:47:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: axel lin X-Patchwork-Id: 699311 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3C6m1v4001964 for ; Tue, 12 Apr 2011 06:48:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756619Ab1DLGr7 (ORCPT ); Tue, 12 Apr 2011 02:47:59 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:48719 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756570Ab1DLGr7 (ORCPT ); Tue, 12 Apr 2011 02:47:59 -0400 Received: by iyb14 with SMTP id 14so6340343iyb.19 for ; Mon, 11 Apr 2011 23:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:cc:content-type:date:message-id :mime-version:x-mailer:content-transfer-encoding; bh=143CTXmL4CEGSa1JHI7BSfrMKZSq+nSq71BD1QoZb+A=; b=MiHHU21gu/HGHA58xI1LCNiXZes/exXnP2mv7ksrDKDKKkboS4wb4s3v67kULHmqYm 45kf73kQcEySqZm0uJ4zFxFJvwo5zoNATIgd/I8a1Xo11pewz6NrJN2Dm9CkTZNp/wUj C+ywyNkeOMhMCibCWZHNX9fZSl5HsGGbPC62M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=wENjsW54jKU5vGXoT9PGcnK52ZGgIHO1QyHFgS3F8KejYJCiW8lQEohx8esaZ09akY RV7H4zmGdQShBxA5ctX1l95vTPBNAA5t7UF7HZ205GPSdckJ44hRvm9Z37gve/RrtG7O bgam6+hweLvN6Xqn3vHiNoxkuoVhvOJ5nGG+Y= Received: by 10.42.137.198 with SMTP id z6mr9057566ict.261.1302590878343; Mon, 11 Apr 2011 23:47:58 -0700 (PDT) Received: from [59.112.80.50] (59-112-80-50.dynamic.hinet.net [59.112.80.50]) by mx.google.com with ESMTPS id uk4sm4449472icb.21.2011.04.11.23.47.55 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Apr 2011 23:47:57 -0700 (PDT) Subject: [PATCH RESEND] Input: twl4030_keypad - fix potential NULL dereference in twl4030_kp_probe() From: Axel Lin To: linux-kernel@vger.kernel.org Cc: David Brownell , Felipe Balbi , Dmitry Torokhov , linux-input@vger.kernel.org Date: Tue, 12 Apr 2011 14:47:51 +0800 Message-ID: <1302590871.17965.1.camel@phoenix> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 12 Apr 2011 06:48:01 +0000 (UTC) We should first check whether platform data is NULL or not, before dereferencing it to get the keymap. Signed-off-by: Axel Lin Reviewed-by: Felipe Balbi --- drivers/input/keyboard/twl4030_keypad.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c index cc06c4b..a26922c 100644 --- a/drivers/input/keyboard/twl4030_keypad.c +++ b/drivers/input/keyboard/twl4030_keypad.c @@ -332,7 +332,7 @@ static int __devinit twl4030_kp_program(struct twl4030_keypad *kp) static int __devinit twl4030_kp_probe(struct platform_device *pdev) { struct twl4030_keypad_data *pdata = pdev->dev.platform_data; - const struct matrix_keymap_data *keymap_data = pdata->keymap_data; + const struct matrix_keymap_data *keymap_data; struct twl4030_keypad *kp; struct input_dev *input; u8 reg; @@ -344,6 +344,8 @@ static int __devinit twl4030_kp_probe(struct platform_device *pdev) return -EINVAL; } + keymap_data = pdata->keymap_data; + kp = kzalloc(sizeof(*kp), GFP_KERNEL); input = input_allocate_device(); if (!kp || !input) {