From patchwork Wed Aug 14 11:08:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 19107 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AD2B02390D for ; Wed, 14 Aug 2013 11:25:28 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id ht10sf4367295vcb.5 for ; Wed, 14 Aug 2013 04:25:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=mMSMf2+ZCs5mZeZ8Xab3EvlCaEe/j7svUoGZOOnNLVo=; b=iol2rJt6g+DrVcbWpuvb22Uwqa259xrq+SRsjpXOlrfsOP2KMGjJgVuM0ppeS7JgEa 8kMguqjsSk+FC/XeR+3eLSfCFOQjGHwhQDUHC5X1zdf4ks8Q4NxJiXQIJADG2pfkzOvq wmFSpJyYwJRrvF2stRQDDMk4gAJlTByVDRnZAqGNK4HcWZJZRHz6F00cRT/WB2go/k0R meyRhB5OVUXpyZuM4bg9iLevBy8xx5cdVKWq/rug+uRJ57NZSTotmg1Xbpimkk0MJB/m hg54h3grVWGqqg5Si7kG0XP5n7qPw7whSC7eHEamaJn81RwtBU6lg+3MgJiOm9X1GmxA Volw== X-Received: by 10.224.137.137 with SMTP id w9mr9763771qat.6.1376479528344; Wed, 14 Aug 2013 04:25:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.34.176 with SMTP id a16ls2972244qej.63.gmail; Wed, 14 Aug 2013 04:25:28 -0700 (PDT) X-Received: by 10.52.92.73 with SMTP id ck9mr68663vdb.34.1376479528127; Wed, 14 Aug 2013 04:25:28 -0700 (PDT) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id n1si8514945vex.64.2013.08.14.04.25.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Aug 2013 04:25:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.52; Received: by mail-vb0-f52.google.com with SMTP id f12so7397666vbg.25 for ; Wed, 14 Aug 2013 04:25:28 -0700 (PDT) X-Gm-Message-State: ALoCoQl3j1q8oijRMY0sOdinq9uC6vNlue8/AiaGTiAQT2d1npIxfIdm9Z+RqcFaVOi0kB7cHgGi X-Received: by 10.221.40.10 with SMTP id to10mr9198773vcb.22.1376479528049; Wed, 14 Aug 2013 04:25:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp207339vcz; Wed, 14 Aug 2013 04:25:27 -0700 (PDT) X-Received: by 10.68.218.199 with SMTP id pi7mr9381587pbc.19.1376479526951; Wed, 14 Aug 2013 04:25:26 -0700 (PDT) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by mx.google.com with ESMTPS id ql10si27937180pbb.10.2013.08.14.04.25.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Aug 2013 04:25:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.48 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.48; Received: by mail-pa0-f48.google.com with SMTP id kp13so9975009pab.35 for ; Wed, 14 Aug 2013 04:25:26 -0700 (PDT) X-Received: by 10.68.210.103 with SMTP id mt7mr950139pbc.179.1376479526490; Wed, 14 Aug 2013 04:25:26 -0700 (PDT) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id xs1sm4552370pac.7.2013.08.14.04.25.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Aug 2013 04:25:25 -0700 (PDT) From: Sachin Kamat To: dri-devel@lists.freedesktop.org Cc: inki.dae@samsung.com, jy0922.shim@samsung.com, sw0312.kim@samsung.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 4/4] drm/exynos: Add NULL pointer check Date: Wed, 14 Aug 2013 16:38:03 +0530 Message-Id: <1376478483-13512-4-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1376478483-13512-1-git-send-email-sachin.kamat@linaro.org> References: <1376478483-13512-1-git-send-email-sachin.kamat@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , devm_kzalloc can fail. Hence check the pointer to avoid NULL pointer dereferencing. Signed-off-by: Sachin Kamat --- drivers/gpu/drm/exynos/exynos_drm_iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.c b/drivers/gpu/drm/exynos/exynos_drm_iommu.c index 3799d5c..fb8db03 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.c +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.c @@ -47,10 +47,16 @@ int drm_create_iommu_mapping(struct drm_device *drm_dev) dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL); + if (!dev->dma_parms) + goto error; + dma_set_max_seg_size(dev, 0xffffffffu); dev->archdata.mapping = mapping; return 0; +error: + arm_iommu_release_mapping(mapping); + return -ENOMEM; } /* @@ -91,6 +97,9 @@ int drm_iommu_attach_device(struct drm_device *drm_dev, subdrv_dev->dma_parms = devm_kzalloc(subdrv_dev, sizeof(*subdrv_dev->dma_parms), GFP_KERNEL); + if (!subdrv_dev->dma_parms) + return -ENOMEM; + dma_set_max_seg_size(subdrv_dev, 0xffffffffu); ret = arm_iommu_attach_device(subdrv_dev, dev->archdata.mapping);