From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 425502D6E58 for ; Tue, 26 May 2026 13:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779801420; cv=none; b=d55gkVAZ/9m4m4VyQKPc90diESRSEeH1X6EXIXVllUgq3sitiG1spBprqs+xyWBdwq2bdqVNZyERBcMvjaa8+rR79qJZEjScVSWZxkz8ahhJJpbIidat25HD+eSg0oFkfAnRI611FoOnPAquEsh43tbefGKJn4oDyPxXVnUTOEo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779801420; c=relaxed/simple; bh=klgl9B5jnGLSkApeko2lPxULEh49WhCLkYIMjnZgEaI=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=nHeODnRbXzK4VZw2va7uVgNxLYqEWj3GrlB08EaRQZlskKRSh4wReQGO02o/Ref2nRPmA3gmzsdb0oQFLHrucBLk9wf1hYF1zZKmmLipk1I/GbN3Evk7fWBYKYOxXApnM+LHEeGU316WmV0yqWR6kAJ4U3GOKylOYdTMbe1SL+c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cG214dNa; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cG214dNa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24B471F000E9; Tue, 26 May 2026 13:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779801418; bh=JE0l0J/Q4cmSCbkBtHlHYstq0L2VtzMwueKDyLmSf5U=; h=Date:Subject:Cc:To:From:References:In-Reply-To; b=cG214dNa11lOiy46AORsXkv4bUe7G6t792Zz1McUEExu49YQuzsGWtnjMFhpT/q5B MrWm4yWs+7MGpCUCObANSrsl8H/A53DJXfmh/222L8XI5XR3vgOsg9FTL9a5N4RvVF /IQgh/8GaVvCxaAdLesrjnrwjwBy5AMiFXGJQityPEoWKRCSgP5efR4ZjeTTgOJezo PwBvoko/tjwmeO2XhNDL2BKxA1yJcrPddVH1UdV4FzAY7pxcLcCPIn4RxUalJYhNwW azzU0WcX+XhCrOXM7HeDL8YEIyMvt8RdnFSmqajqRMyEIyISiN7yQG8bwpdY8bRSrW +HGWRV9/6y6MA== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 26 May 2026 15:16:54 +0200 Message-Id: Subject: Re: [PATCH] nouveau/gsp: fix NULL pointer dereference in r535 nvenc/ofs alloc Cc: , , , , , , , , , , , , To: "Hongling Zeng" From: "Danilo Krummrich" References: <20260526014721.13299-1-zenghongling@kylinos.cn> In-Reply-To: <20260526014721.13299-1-zenghongling@kylinos.cn> On Tue May 26, 2026 at 3:47 AM CEST, Hongling Zeng wrote: > nvkm_gsp_rm_alloc_get() can return NULL as well as error pointers. > The current code only checks for error pointers with IS_ERR(), which > would lead to a NULL pointer dereference if NULL is returned. > > Fix by using IS_ERR_OR_NULL() instead of IS_ERR(), matching the > pattern used in nvkm_gsp_rm_alloc(). There was a similar patch [1] a while ago for another callsite. I replied: Are we sure that this can ever return NULL in the first place? I know that nvkm_gsp_rm_alloc_get() internally checks for IS_ERR_OR_NULL(), but I couldn't find anything within the callchain that would actually return NULL. =09 That said, I think IS_ERR_OR_NULL() checks are misleading. Is there a real case where NULL can be returned? If not, let's remove the IS_ERR_OR_NULL() throughout the whole chain instead. [1] https://lore.kernel.org/lkml/20260418071412.86022-1-sunliming@linux.dev= /