From patchwork Thu Jul 26 10:28:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 1241441 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 9C5B5DFFBF for ; Thu, 26 Jul 2012 10:44:25 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SuLTb-0000tA-40; Thu, 26 Jul 2012 10:39:27 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SuLJp-0008FU-Ii for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2012 10:29:39 +0000 Received: by mail-we0-f177.google.com with SMTP id r3so1339380wey.36 for ; Thu, 26 Jul 2012 03:29:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Lxskf/qRq7hg6KpJ/X2f1VVvxMLTgHDr80t5ugMYNbE=; b=cNkBpYCEYNPzDmsTYTzrUayL5R02NhZq9rcIs5SwJZNI46HBzc5uqoxaxFV47E+GwF h6xrRFHa76ASQ8xnMjHTRLcuwrol/hRcI8bcW+k4w3HOeEk4VU1vvj8GFXvMlIgr1Nu2 UXc+MlCxZTdeuk9vkB5vXOK+C+5a3GehHy+S1zbE2B9s51A1CdlQmemnRpVWaqWDVZFh fQpwLNyRryqcvE0GdIADZnhTH36jlVJJKSOS+KoR5WIS6Qy8YWg7gDOs/70qsj68XyMb ixJBcAC0GVONssLwD6sGn9kWN3HoRa5UdHCtvUy2H17o76SHLKSQzR5mVCc6yUa3Kc2Q oUNA== Received: by 10.216.137.76 with SMTP id x54mr4085688wei.189.1343298558546; Thu, 26 Jul 2012 03:29:18 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id fb20sm11559455wid.1.2012.07.26.03.29.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 03:29:17 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/21] ASoC: ux500: Strengthen error checking after memory allocation Date: Thu, 26 Jul 2012 11:28:37 +0100 Message-Id: <1343298534-13611-5-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343298534-13611-1-git-send-email-lee.jones@linaro.org> References: <1343298534-13611-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQlyzlF+7xoEowoRq+B4vDAxcYb7ZgTSX07JnYDiT38fEPmcLorbW5wn50kveqO6l01qBg/1 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: ola.o.lilja@stericsson.com, alsa-devel@alsa-project.org, linus.walleij@stericsson.com, arnd@arndb.de, broonie@opensource.wolfsonmicro.com, olalilja@yahoo.se, STEricsson_nomadik_linux@list.st.com, Lee Jones , lrg@ti.com, sameo@linux.intel.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently there is no out-of-memory error checking after attempting to allocate memory for the ux500_msp or ux500_msp_i2s_drvdata data structures. Instead we go about populating them regardless. This patch applies the necessary error checking to prevent a panic. Signed-off-by: Lee Jones --- sound/soc/ux500/ux500_msp_dai.c | 3 +++ sound/soc/ux500/ux500_msp_i2s.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/sound/soc/ux500/ux500_msp_dai.c b/sound/soc/ux500/ux500_msp_dai.c index 62ac0285..cdbbdaf 100644 --- a/sound/soc/ux500/ux500_msp_dai.c +++ b/sound/soc/ux500/ux500_msp_dai.c @@ -760,6 +760,9 @@ static int __devinit ux500_msp_drv_probe(struct platform_device *pdev) drvdata = devm_kzalloc(&pdev->dev, sizeof(struct ux500_msp_i2s_drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + drvdata->fmt = 0; drvdata->slots = 1; drvdata->tx_mask = 0x01; diff --git a/sound/soc/ux500/ux500_msp_i2s.c b/sound/soc/ux500/ux500_msp_i2s.c index ee14d2d..4c79850 100644 --- a/sound/soc/ux500/ux500_msp_i2s.c +++ b/sound/soc/ux500/ux500_msp_i2s.c @@ -673,6 +673,8 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev, *msp_p = devm_kzalloc(&pdev->dev, sizeof(struct ux500_msp), GFP_KERNEL); msp = *msp_p; + if (!msp) + return -ENOMEM; msp->id = platform_data->id; msp->dev = &pdev->dev;