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: 10251 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D479823E56 for ; Thu, 26 Jul 2012 10:29:20 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id A4EDFA18866 for ; Thu, 26 Jul 2012 10:29:20 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so1770591yen.11 for ; Thu, 26 Jul 2012 03:29:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Lxskf/qRq7hg6KpJ/X2f1VVvxMLTgHDr80t5ugMYNbE=; b=iaDXIWlQRNpB9Ee2ms+gg2jyMZBO0VSRJ0vMY8FfcVJipOVDdrgTVc8fc/Y/kUZMyR G1rS0yQvQ7Qozwvbh9O4hj7HbkyAVbWEpBhfyFMFFFeQD61oAs1vNOmQ1x5O4Gy3pNNG 5iXybv6XEtICcmBNg/QoQLAMgHLUvXPaAKdJtfWCgk6TEgfXgfY+F/bOcRLFxlYk5lDG avamTzEbmA0NltPZd8VrxM8OpIM0UTXqbKH1gCrrxpScc04al/pglQYlLcH4SeOHDj4Y ySmCHapvcOk+KW/XL+KUFJZGelYoIij2nYl5grUi9M9V0peRLp+i5l+Gdc2NvY2CyvvF fbwQ== Received: by 10.42.22.206 with SMTP id p14mr27994081icb.23.1343298560291; Thu, 26 Jul 2012 03:29:20 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.43.93.3 with SMTP id bs3csp133351icc; Thu, 26 Jul 2012 03:29:19 -0700 (PDT) Received: by 10.180.86.106 with SMTP id o10mr12227297wiz.22.1343298559052; Thu, 26 Jul 2012 03:29:19 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id b19si27884710wel.147.2012.07.26.03.29.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 03:29:19 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wg0-f50.google.com with SMTP id ds11so1580987wgb.31 for ; Thu, 26 Jul 2012 03:29:18 -0700 (PDT) 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 Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, broonie@opensource.wolfsonmicro.com, sameo@linux.intel.com, olalilja@yahoo.se, ola.o.lilja@stericsson.com, alsa-devel@alsa-project.org, lrg@ti.com, Lee Jones 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: ALoCoQmrRaAVn8CgEerCZkLZURQXuWA2cdWAAQjn9fegMe2oolUsFDEAIVr6c2a/Ht5fo4rGHkGX 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;