From patchwork Mon Jan 17 10:08:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasiliy Kulikov X-Patchwork-Id: 483431 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 p0HA8gE2007503 for ; Mon, 17 Jan 2011 10:08:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751372Ab1AQKIk (ORCPT ); Mon, 17 Jan 2011 05:08:40 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:54738 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751033Ab1AQKIi (ORCPT ); Mon, 17 Jan 2011 05:08:38 -0500 Received: by eye27 with SMTP id 27so2387511eye.19 for ; Mon, 17 Jan 2011 02:08:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer; bh=xNfkod8ARGZj94BKbJQptq8ym3Y+5okBtFSWH5KBaUc=; b=mfvEi3jWLP8BML/dlVlRwMOK0qSbW1Y6ExXnbt4ijwg2GuaSokR4a6m0AvI3qva+Qt YQ23nsIx7jefuJUDboyLgo2cWTC9Pkl+YFUACTmt4Q0tSNlWvkRveptpGqVvIVY2rz/9 3HtfxrlvKphjH7Bv04BnM9tkee51uYiuJJ6so= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=EW8qGoreSS1uVgYrc+mG8YdpGAwMuVQzv0DAuR3hhxNtdLca5D7Ak6MLC9TZlTQkWO w/3spP705EabwOfPVZJd6vfYJfP391USvqFvGoDt9syzVETGaS/I6swLpPGTOzneavh0 4GModmzTXgm17j/5h8qligAz/YgkSEPUjv+oU= Received: by 10.213.34.2 with SMTP id j2mr2348670ebd.16.1295258917160; Mon, 17 Jan 2011 02:08:37 -0800 (PST) Received: from localhost (ppp85-140-161-155.pppoe.mtu-net.ru [85.140.161.155]) by mx.google.com with ESMTPS id b52sm3468885eei.19.2011.01.17.02.08.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 17 Jan 2011 02:08:36 -0800 (PST) From: Vasiliy Kulikov To: kernel-janitors@vger.kernel.org Cc: Tony Lindgren , Russell King , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arm: mach-omap2: potential NULL dereference Date: Mon, 17 Jan 2011 13:08:32 +0300 Message-Id: <1295258913-31048-1-git-send-email-segoon@openwall.com> X-Mailer: git-send-email 1.7.0.4 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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]); Mon, 17 Jan 2011 10:08:42 +0000 (UTC) diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c index b1e0af1..20fccfb 100644 --- a/arch/arm/mach-omap2/sr_device.c +++ b/arch/arm/mach-omap2/sr_device.c @@ -40,7 +40,7 @@ static struct omap_device_pm_latency omap_sr_latency[] = { }; /* Read EFUSE values from control registers for OMAP3430 */ -static void __init sr_set_nvalues(struct omap_volt_data *volt_data, +static int __init sr_set_nvalues(struct omap_volt_data *volt_data, struct omap_sr_data *sr_data) { struct omap_sr_nvalue_table *nvalue_table; @@ -51,6 +51,8 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data, nvalue_table = kzalloc(sizeof(struct omap_sr_nvalue_table)*count, GFP_KERNEL); + if (nvalue_table == NULL) + return -ENOMEM; for (i = 0; i < count; i++) { u32 v; @@ -75,6 +77,8 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data, sr_data->nvalue_table = nvalue_table; sr_data->nvalue_count = count; + + return 0; } static int sr_dev_init(struct omap_hwmod *oh, void *user) @@ -84,15 +88,18 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user) struct omap_volt_data *volt_data; char *name = "smartreflex"; static int i; + int err = 0; sr_data = kzalloc(sizeof(struct omap_sr_data), GFP_KERNEL); if (!sr_data) { + err = -ENOMEM; pr_err("%s: Unable to allocate memory for %s sr_data.Error!\n", __func__, oh->name); - return -ENOMEM; + goto exit; } if (!oh->vdd_name) { + err = -EINVAL; pr_err("%s: No voltage domain specified for %s." "Cannot initialize\n", __func__, oh->name); goto exit; @@ -104,6 +111,7 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user) sr_data->voltdm = omap_voltage_domain_lookup(oh->vdd_name); if (IS_ERR(sr_data->voltdm)) { + err = PTR_ERR(sr_data->voltdm); pr_err("%s: Unable to get voltage domain pointer for VDD %s\n", __func__, oh->vdd_name); goto exit; @@ -111,12 +119,15 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user) omap_voltage_get_volttable(sr_data->voltdm, &volt_data); if (!volt_data) { + err = -EINVAL; pr_warning("%s: No Voltage table registerd fo VDD%d." "Something really wrong\n\n", __func__, i + 1); goto exit; } - sr_set_nvalues(volt_data, sr_data); + err = sr_set_nvalues(volt_data, sr_data); + if (err) + goto exit; sr_data->enable_on_init = sr_enable_on_init; @@ -129,7 +140,7 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user) exit: i++; kfree(sr_data); - return 0; + return err; } /*