From patchwork Mon Sep 17 09:50:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 11459 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 ADD2623E42 for ; Mon, 17 Sep 2012 09:53:56 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1E99AA18D0D for ; Mon, 17 Sep 2012 09:53:56 +0000 (UTC) Received: by iafj25 with SMTP id j25so5006115iaf.11 for ; Mon, 17 Sep 2012 02:53:55 -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=MDDolncWzJOYid9KsjjTpFZOkzKOKRrL+rKrZ4UnlXY=; b=jWG6GezsvTYl3us2CN+/GbvsBfcD56kpN4FSKnhAp8jopfx+aKGWhyRQFzc83ei1/W PuJe5To9E/ntnqNJNM+d/bZRR4oybMrNq8CgIKTwZ/XU91+tod63Typri+2hLv/UMm5S aAAVlSm9rRQBY8CHeK2vnW2ZOzaZhBdPJCRui4kDhJ6QyZUGS21I4CvXPPj8f+9ruqrq pZTU6JFwNOYPNOgE0tv+nGpOWc76MzCDiPnBUu0+SB7wv8cXOyTJLbo7gcMQeqQXz8GW TfCKmcxyenspGGtYMMsZElLarMiiRHCkWhl6FdixPbkTjOz4jlZWgZv8fGURg/hpc8yd nvgA== Received: by 10.42.60.139 with SMTP id q11mr8242177ich.53.1347875635477; Mon, 17 Sep 2012 02:53:55 -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.50.184.232 with SMTP id ex8csp305227igc; Mon, 17 Sep 2012 02:53:54 -0700 (PDT) Received: by 10.68.129.73 with SMTP id nu9mr22060258pbb.59.1347875634491; Mon, 17 Sep 2012 02:53:54 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id px5si14891965pbb.322.2012.09.17.02.53.54 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 02:53:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pb0-f50.google.com with SMTP id md12so10049567pbc.37 for ; Mon, 17 Sep 2012 02:53:54 -0700 (PDT) Received: by 10.66.90.1 with SMTP id bs1mr19503593pab.13.1347875634214; Mon, 17 Sep 2012 02:53:54 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id st6sm6670119pbc.58.2012.09.17.02.53.50 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 02:53:53 -0700 (PDT) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: vinod.koul@intel.com, jassisinghbrar@gmail.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 2/2] DMA: PL330: Check the pointer returned by kzalloc Date: Mon, 17 Sep 2012 15:20:23 +0530 Message-Id: <1347875423-7970-2-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1347875423-7970-1-git-send-email-sachin.kamat@linaro.org> References: <1347875423-7970-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQnNRjk/V8cQe0UhIDHWejNasdUvwtVcTCp3gfgJv7KAs5ZuIZ8IwPq4hsV5kV+qklLLiko6 kzalloc could return NULL. Hence add a check to avoid NULL pointer dereference. Signed-off-by: Sachin Kamat Acked-by: Jassi Brar --- drivers/dma/pl330.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 018a445..5d3bbcd 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2930,6 +2930,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan); pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); + if (!pdmac->peripherals) { + ret = -ENOMEM; + dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n"); + goto probe_err5; + } for (i = 0; i < num_chan; i++) { pch = &pdmac->peripherals[i];