From patchwork Tue Jun 18 10:14:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tuomas Tynkkynen X-Patchwork-Id: 252217 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 171882C0077 for ; Tue, 18 Jun 2013 20:16:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756016Ab3FRKPB (ORCPT ); Tue, 18 Jun 2013 06:15:01 -0400 Received: from hqemgate04.nvidia.com ([216.228.121.35]:17716 "EHLO hqemgate04.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755716Ab3FRKO7 (ORCPT ); Tue, 18 Jun 2013 06:14:59 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Tue, 18 Jun 2013 03:15:10 -0700 Received: from hqemhub02.nvidia.com ([172.20.12.94]) by hqnvupgp07.nvidia.com (PGP Universal service); Tue, 18 Jun 2013 03:13:24 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 18 Jun 2013 03:13:24 -0700 Received: from ttynkkynen-lnx.Nvidia.com (172.20.144.16) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.298.1; Tue, 18 Jun 2013 03:14:55 -0700 From: Tuomas Tynkkynen To: Samuel Ortiz , Mark Brown , Wolfram Sang CC: , , , Linus Walleij , Tuomas Tynkkynen Subject: [PATCH v2 2/2] regulator: tps62360: Fix crash in i2c_driver .probe Date: Tue, 18 Jun 2013 13:14:41 +0300 Message-ID: <1371550481-28126-3-git-send-email-ttynkkynen@nvidia.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1371550481-28126-1-git-send-email-ttynkkynen@nvidia.com> References: <1371550481-28126-1-git-send-email-ttynkkynen@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Commit "i2c: core: make it possible to match a pure device tree driver" changed semantics of the i2c probing for device tree devices. Device tree probed devices now get a NULL i2c_device_id pointer. This caused kernel panics due to NULL dereference. Tested-by: Stephen Warren Reviewed-by: Stephen Warren Signed-off-by: Tuomas Tynkkynen --- v2: Added Stephen's Tested-by & Reviewed-by drivers/regulator/tps62360-regulator.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 612919c..a490d5b 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c @@ -351,7 +351,6 @@ static int tps62360_probe(struct i2c_client *client, int chip_id; pdata = client->dev.platform_data; - chip_id = id->driver_data; if (client->dev.of_node) { const struct of_device_id *match; @@ -364,6 +363,11 @@ static int tps62360_probe(struct i2c_client *client, chip_id = (int)match->data; if (!pdata) pdata = of_get_tps62360_platform_data(&client->dev); + } else if (id) { + chip_id = id->driver_data; + } else { + dev_err(&client->dev, "No device tree match or id table match found\n"); + return -ENODEV; } if (!pdata) { @@ -402,7 +406,7 @@ static int tps62360_probe(struct i2c_client *client, return -ENODEV; } - tps->desc.name = id->name; + tps->desc.name = client->name; tps->desc.id = 0; tps->desc.ops = &tps62360_dcdc_ops; tps->desc.type = REGULATOR_VOLTAGE;