From patchwork Thu Nov 8 09:01:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 12764 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 7B4E023E28 for ; Thu, 8 Nov 2012 09:07:12 +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 1074EA189AA for ; Thu, 8 Nov 2012 09:07:11 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so3665254iej.11 for ; Thu, 08 Nov 2012 01:07:11 -0800 (PST) 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=7L7FZdwgOotZSwPBkogalh8yBwrYCiAXqgVtcT1UkQQ=; b=ktBCMDim8wTTF8VPxjl3XpgWWzwQI4VHcrchBxt2+j1hErkV6oR4+54TE68o4wIONK TYxApmsrYNJSaaIHbntFqtgObWxqEMBEtRYe0HzOzb1bukwJ60nSZTpLw2v3ZpmpaA+L Sv0s3TA3XZA9jn70lumf0t7atXXN0PFhrWpwUnmUMAmZ5JogMxvKsfdanA0OrFH2hoaq 7BW7uMBP3k8/lrqBYE2uQK+UXDhXicixgLl+4jQNYl/BabYnOJZ3PjwTvyY5kr5hLtgJ ZYEUJT3ulqa354I4Gi6XUW2doVVkZGZk8ksRMWE/om7J4KXawt4vwAr3y8a+2yfNdQRt B/CA== Received: by 10.42.203.146 with SMTP id fi18mr6442491icb.18.1352365631513; Thu, 08 Nov 2012 01:07:11 -0800 (PST) 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.67.148 with SMTP id n20csp341476igt; Thu, 8 Nov 2012 01:07:11 -0800 (PST) Received: by 10.68.136.135 with SMTP id qa7mr21866227pbb.157.1352365630574; Thu, 08 Nov 2012 01:07:10 -0800 (PST) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by mx.google.com with ESMTPS id yk3si34850725pbc.39.2012.11.08.01.07.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 08 Nov 2012 01:07:10 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.42 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.42; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.42 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-pa0-f42.google.com with SMTP id fa1so1813606pad.29 for ; Thu, 08 Nov 2012 01:07:10 -0800 (PST) Received: by 10.66.76.98 with SMTP id j2mr20397457paw.65.1352365630190; Thu, 08 Nov 2012 01:07:10 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id gl9sm15630662pbc.51.2012.11.08.01.07.06 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 08 Nov 2012 01:07:09 -0800 (PST) From: Sachin Kamat To: linux-samsung-soc@vger.kernel.org Cc: kgene.kim@samsung.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 1/1] ARM: S3C24XX: Fix potential NULL pointer dereference error Date: Thu, 8 Nov 2012 14:31:31 +0530 Message-Id: <1352365291-32433-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQmiRTj3ub8SrtdPxeRrSB76wnW91f/o7huoCWFXW9z8n08gzTdhjnUU7CIklZ0jfrfI/tW7 chan->end is tested for being NULL. However in the event that it is NULL, the subsequent assignment statement would lead to NULL pointer dereference. Thus dereferencing it only when it is not NULL. Signed-off-by: Sachin Kamat --- Based on Kukjin Kim's for-next branch. Compile tested. --- arch/arm/plat-s3c24xx/dma.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm/plat-s3c24xx/dma.c b/arch/arm/plat-s3c24xx/dma.c index db98e70..0abd1c4 100644 --- a/arch/arm/plat-s3c24xx/dma.c +++ b/arch/arm/plat-s3c24xx/dma.c @@ -473,12 +473,13 @@ int s3c2410_dma_enqueue(enum dma_ch channel, void *id, pr_debug("dma%d: %s: buffer %p queued onto non-empty channel\n", chan->number, __func__, buf); - if (chan->end == NULL) + if (chan->end == NULL) { pr_debug("dma%d: %s: %p not empty, and chan->end==NULL?\n", chan->number, __func__, chan); - - chan->end->next = buf; - chan->end = buf; + } else { + chan->end->next = buf; + chan->end = buf; + } } /* if necessary, update the next buffer field */