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: 2844930 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 308BC9F271 for ; Thu, 15 Aug 2013 00:19:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6184C2062D for ; Thu, 15 Aug 2013 00:19:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 80E5520627 for ; Thu, 15 Aug 2013 00:19:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 592CFE6D59 for ; Wed, 14 Aug 2013 17:19:21 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by gabe.freedesktop.org (Postfix) with ESMTP id C50A143A47 for ; Wed, 14 Aug 2013 04:25:26 -0700 (PDT) Received: by mail-pa0-f50.google.com with SMTP id fb10so10034822pad.37 for ; Wed, 14 Aug 2013 04:25:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mMSMf2+ZCs5mZeZ8Xab3EvlCaEe/j7svUoGZOOnNLVo=; b=aNW8W99Q7kU7ecurdMXs8zEp3gelMVItW40QGTg7AgbUBirsaNgVlKeTKoM7guQqYq DuAEqf+PJjpICt7q8QOwCtlNhOpE4jlHZbPgHEEf2VamSXf5vfDMOC3Qc/zl1S3hXFVl 8/GAUh//gPtlMipYbN2cZaBQYw7SpKVbIIc5dM25rfdVNFULFSWHpoBSE3AjIiQ/5baO Gnyt1etXTMXAnJuoSoaK8xOxVc9ND9B5nesC5CSddJz+rP8jurdUionzVIVPK3sUbyFp HYrD42cH1BA1yi5xqD2uWqNyIVb0mhcP3Omu267ryXzFUNjQ6JJjJTu1vpuSSLcn6Nqw R8lw== X-Gm-Message-State: ALoCoQlQgEl/iIuGx9Yzfz1ezV5MSYiWOBptL0w46A23jek6xw6wQ0BHz6y37bWOaEh9wqMtanSw 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 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-Mailman-Approved-At: Wed, 14 Aug 2013 17:11:05 -0700 Cc: sachin.kamat@linaro.org, sw0312.kim@samsung.com, patches@linaro.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);