From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750783AbdAXJzp (ORCPT ); Tue, 24 Jan 2017 04:55:45 -0500 Received: from pegasos-out.vodafone.de ([80.84.1.38]:53013 "EHLO pegasos-out.vodafone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbdAXJzo (ORCPT ); Tue, 24 Jan 2017 04:55:44 -0500 X-Spam-Flag: NO X-Spam-Score: -0.044 Authentication-Results: rohrpostix2.prod.vfnet.de (amavisd-new); dkim=pass header.i=@vodafone.de X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de 924906600FB Subject: Re: [PATCH] drm/amd/amdgpu/amdgpu_ttm: Handle return NULL error from ioremap_nocache To: Arvind Yadav , airlied@linux.ie References: <1485249933-1055-1-git-send-email-arvind.yadav.cs@gmail.com> Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Tue, 24 Jan 2017 10:55:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1485249933-1055-1-git-send-email-arvind.yadav.cs@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 24.01.2017 um 10:25 schrieb Arvind Yadav: > Here, If ioremap_nocache will fail. It will return NULL. > Kernel can run into a NULL-pointer dereference. > This error check will avoid NULL pointer dereference. > > Signed-off-by: Arvind Yadav I'm not 100% sure if ioremap_nocache() can actually return NULL on platforms where this matters, but if that's the case the patch looks reasonable on first glance. So it is Reviewed-by: Christian König . Regards, Christian. > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > index 8e35c1f..610c88f 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > @@ -552,6 +552,8 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_ > mem->bus.addr = > ioremap_nocache(mem->bus.base + mem->bus.offset, > mem->bus.size); > + if (!mem->bus.addr) > + return -ENOMEM; > > /* > * Alpha: Use just the bus offset plus