From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73E20C28B30 for ; Sun, 23 Mar 2025 18:10:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1850810E14C; Sun, 23 Mar 2025 18:10:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="OelJyDht"; dkim-atps=neutral X-Greylist: delayed 540 seconds by postgrey-1.36 at gabe; Sun, 23 Mar 2025 18:10:42 UTC Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3168E10E14C for ; Sun, 23 Mar 2025 18:10:41 +0000 (UTC) Received: from [192.168.1.37] ([90.11.132.44]) by smtp.orange.fr with ESMTPA id wPdZtqcs4vQV0wPdctbi88; Sun, 23 Mar 2025 19:01:35 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1742752895; bh=zp3UcKJhUjE7ySXeU2dEz0mIKPMzZc8r54esOzKpgeQ=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=OelJyDhtUiXn/3ZG0LOI5TjhwxvoaXoK9D1LUxe7j9eMo7tyWD+Si2DSO2zHRbynE 8E18tkmJ1GiiQuKPDzLThmDhtE6TTjrdNI1edhccNt6tPcfIN9Xmwr3O3UMyflNSYP mlxRUzsl5jps9W+KhAyT6AiVmkDkPH7fmeEE3mv/L5EtmPq7C1q84INnpvO6//bpdm cWI4ORMUWlw2FcMDY9foxevsA6WfP7rCkr7ChmR8+CyaSlqmip9jZr+SLNQTbUc9JN Pn6urrO6ViumWpAlyYxfRPfY7FIqe+/Kpu9jElZ/ItY2E3MRkICnAK4CjqYJ1h0euN 1y//Erg9ytZVA== X-ME-Helo: [192.168.1.37] X-ME-Auth: bWFyaW9uLmphaWxsZXRAd2FuYWRvby5mcg== X-ME-Date: Sun, 23 Mar 2025 19:01:35 +0100 X-ME-IP: 90.11.132.44 Message-ID: Date: Sun, 23 Mar 2025 19:01:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/xe/svm: fix dereferencing error pointer in drm_gpusvm_range_alloc() To: Harshit Mogalapalli , Lucas De Marchi , =?UTF-8?Q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , David Airlie , Simona Vetter , Matthew Brost , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org, error27@gmail.com References: <20250323124907.3946370-1-harshit.m.mogalapalli@oracle.com> Content-Language: en-US, fr-FR From: Christophe JAILLET In-Reply-To: <20250323124907.3946370-1-harshit.m.mogalapalli@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Le 23/03/2025 à 13:49, Harshit Mogalapalli a écrit : > xe_svm_range_alloc() returns ERR_PTR(-ENOMEM) on failure and there is a > dereference of "range" after that: > > --> range->gpusvm = gpusvm; > > In xe_svm_range_alloc(), when memory allocation fails return NULL > instead to handle this situation. > > Fixes: 99624bdff867 ("drm/gpusvm: Add support for GPU Shared Virtual Memory") > Reported-by: Dan Carpenter > Closes: https://lore.kernel.org/all/adaef4dd-5866-48ca-bc22-4a1ddef20381@stanley.mountain/ > Signed-off-by: Harshit Mogalapalli > --- > This is based on static analysis and only compile tested. > --- > drivers/gpu/drm/xe/xe_svm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c > index 52e04e7e343f..a79df8cf1f36 100644 > --- a/drivers/gpu/drm/xe/xe_svm.c > +++ b/drivers/gpu/drm/xe/xe_svm.c > @@ -80,7 +80,7 @@ xe_svm_range_alloc(struct drm_gpusvm *gpusvm) > > range = kzalloc(sizeof(*range), GFP_KERNEL); > if (!range) > - return ERR_PTR(-ENOMEM); > + return NULL; > > INIT_LIST_HEAD(&range->garbage_collector_link); > xe_vm_get(gpusvm_to_vm(gpusvm)); Reviewed-by: Christophe JAILLET