From patchwork Mon Sep 17 09:50:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 11458 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 C982523E42 for ; Mon, 17 Sep 2012 09:53:53 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id CD3ECA1BF89 for ; Mon, 17 Sep 2012 09:53:52 +0000 (UTC) Received: by ieak11 with SMTP id k11so8956995iea.11 for ; Mon, 17 Sep 2012 02:53:52 -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:x-gm-message-state; bh=vPH+CHTaoS/iPTm6U7LiCMMb0xBP21DFhPC5Hz4lExM=; b=LcROAIRI62Esm4th+8HbUca7sQQtUoTXT8GGwx2lREB0viKjlnhMFswfxIooS+8A0Q a++8wct2AgIP0IU4VtOQvyW7hv8jZj0a8471Owuk7IgsPuid2sZm82QzepCuR7pMabOL U8CofMDXIF1MQeIHpbO4a+cSp/CortGdqPZSMgHLRMk6bgMWIPLcfgyFiLVTrX6FoEhJ W/sYcLUoRZp9eMXh/93wDadoFkfqcvQNQWUYyOWgBL89oaCw8Djjeg4n5Qe0SKPtMsx3 PSSw923FBsihtmFeSxU+nAtslCEh1T3+oZKhNA9vH7/R2soL/SCziiPKbTm2DM1Xn0u1 wepA== Received: by 10.50.89.164 with SMTP id bp4mr6126082igb.28.1347875632194; Mon, 17 Sep 2012 02:53:52 -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 ex8csp305223igc; Mon, 17 Sep 2012 02:53:51 -0700 (PDT) Received: by 10.68.239.135 with SMTP id vs7mr21709716pbc.38.1347875631378; Mon, 17 Sep 2012 02:53:51 -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 hf4si14973882pbc.19.2012.09.17.02.53.50 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 02:53:51 -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 pbcmd12 with SMTP id md12so10049566pbc.37 for ; Mon, 17 Sep 2012 02:53:50 -0700 (PDT) Received: by 10.66.76.165 with SMTP id l5mr19278894paw.79.1347875630596; Mon, 17 Sep 2012 02:53:50 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id st6sm6670119pbc.58.2012.09.17.02.53.46 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 02:53:49 -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 1/2] DMA: PL330: Fix potential NULL pointer dereference in pl330_submit_req() Date: Mon, 17 Sep 2012 15:20:22 +0530 Message-Id: <1347875423-7970-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQkDO9iuYCKska0Q89kOjp6/yMpMQY7ZCVRyHzAjqodHId8k+Yj5aq6b8mk2mPMOOpwGtVzQ 'r->cfg' is being checked for NULL. However, it is dereferenced in the previous statements. Thus moving those statements within the check. Signed-off-by: Sachin Kamat --- drivers/dma/pl330.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 2343d7d..018a445 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -1567,17 +1567,19 @@ static int pl330_submit_req(void *ch_id, struct pl330_req *r) goto xfer_exit; } - /* Prefer Secure Channel */ - if (!_manager_ns(thrd)) - r->cfg->nonsecure = 0; - else - r->cfg->nonsecure = 1; /* Use last settings, if not provided */ - if (r->cfg) + if (r->cfg) { + /* Prefer Secure Channel */ + if (!_manager_ns(thrd)) + r->cfg->nonsecure = 0; + else + r->cfg->nonsecure = 1; + ccr = _prepare_ccr(r->cfg); - else + } else { ccr = readl(regs + CC(thrd->id)); + } /* If this req doesn't have valid xfer settings */ if (!_is_valid(ccr)) {