[AMD Official Use Only - AMD Internal Distribution Only] Thanks for the catch,
Reviewed-by: Tao Zhou <[email protected]> > -----Original Message----- > From: Zilin Guan <[email protected]> > Sent: Thursday, January 29, 2026 4:35 PM > To: Deucher, Alexander <[email protected]> > Cc: Koenig, Christian <[email protected]>; [email protected]; > [email protected]; Zhou1, Tao <[email protected]>; Zhang, Hawking > <[email protected]>; Chai, Thomas <[email protected]>; Xie, > Patrick <[email protected]>; Yang, Stanley <[email protected]>; > [email protected]; [email protected]; linux- > [email protected]; [email protected]; Zilin Guan <[email protected]> > Subject: [PATCH] drm/amdgpu: Fix memory leak in amdgpu_ras_init() > > When amdgpu_nbio_ras_sw_init() fails in amdgpu_ras_init(), the function > returns > directly without freeing the allocated con structure, leading to a memory > leak. > > Fix this by jumping to the release_con label to properly clean up the > allocated > memory before returning the error code. > > Compile tested only. Issue found using a prototype static analysis tool and > code > review. > > Fixes: fdc94d3a8c88 ("drm/amdgpu: Rework pcie_bif ras sw_init") > Signed-off-by: Zilin Guan <[email protected]> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > index 2a6cf7963dde..8de9f68f7bea 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > @@ -4343,7 +4343,7 @@ int amdgpu_ras_init(struct amdgpu_device *adev) > * to handle fatal error */ > r = amdgpu_nbio_ras_sw_init(adev); > if (r) > - return r; > + goto release_con; > > if (adev->nbio.ras && > adev->nbio.ras->init_ras_controller_interrupt) { > -- > 2.34.1
