linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] drm/msm: Remove dead code in msm_ioctl_gem_submit()
@ 2025-06-23 18:47 I Hsin Cheng
  2025-07-01 19:38 ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: I Hsin Cheng @ 2025-06-23 18:47 UTC (permalink / raw)
  To: robin.clark
  Cc: lumag, abhinav.kumar, jessica.zhang, sean, marijn.suijten,
	airlied, simona, linux-arm-msm, dri-devel, freedreno,
	linux-kernel, shuah, linux-kernel-mentees, I Hsin Cheng

According to the report of Coverity Scan [1], "sync_file" is going to be
NULL when entering the "if" section after "out_post_unlock", so
"fput(sync_file->file)" is never going to be exected in this block.

[1]: https://scan5.scan.coverity.com/#/project-view/10074/10063?selectedIssue=1655089
Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index d4f71bb54e84..cba1dc6fe6c6 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -904,8 +904,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 out_post_unlock:
 	if (ret && (out_fence_fd >= 0)) {
 		put_unused_fd(out_fence_fd);
-		if (sync_file)
-			fput(sync_file->file);
 	}
 
 	if (!IS_ERR_OR_NULL(submit)) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] drm/msm: Remove dead code in msm_ioctl_gem_submit()
  2025-06-23 18:47 [RFC PATCH] drm/msm: Remove dead code in msm_ioctl_gem_submit() I Hsin Cheng
@ 2025-07-01 19:38 ` Shuah Khan
  2025-07-01 20:08   ` Rob Clark
  0 siblings, 1 reply; 3+ messages in thread
From: Shuah Khan @ 2025-07-01 19:38 UTC (permalink / raw)
  To: I Hsin Cheng, robin.clark
  Cc: lumag, abhinav.kumar, jessica.zhang, sean, marijn.suijten,
	airlied, simona, linux-arm-msm, dri-devel, freedreno,
	linux-kernel, shuah, linux-kernel-mentees, Shuah Khan

On 6/23/25 12:47, I Hsin Cheng wrote:
> According to the report of Coverity Scan [1], "sync_file" is going to be
> NULL when entering the "if" section after "out_post_unlock", so
> "fput(sync_file->file)" is never going to be exected in this block.
> 
> [1]: https://scan5.scan.coverity.com/#/project-view/10074/10063?selectedIssue=1655089
> Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
> ---
>   drivers/gpu/drm/msm/msm_gem_submit.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
> index d4f71bb54e84..cba1dc6fe6c6 100644
> --- a/drivers/gpu/drm/msm/msm_gem_submit.c
> +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
> @@ -904,8 +904,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
>   out_post_unlock:
>   	if (ret && (out_fence_fd >= 0)) {
>   		put_unused_fd(out_fence_fd);
> -		if (sync_file)
> -			fput(sync_file->file);

Are you sure you want delete these two lines? It might not make
sense to check sync_file inside if (ret && (out_fence_fd >= 0)),
but it is ncecessary to fput.

>   	}
>   
>   	if (!IS_ERR_OR_NULL(submit)) {

Check the error paths carefully to see if this is indeed the right fix.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] drm/msm: Remove dead code in msm_ioctl_gem_submit()
  2025-07-01 19:38 ` Shuah Khan
@ 2025-07-01 20:08   ` Rob Clark
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Clark @ 2025-07-01 20:08 UTC (permalink / raw)
  To: Shuah Khan
  Cc: I Hsin Cheng, lumag, abhinav.kumar, jessica.zhang, sean,
	marijn.suijten, airlied, simona, linux-arm-msm, dri-devel,
	freedreno, linux-kernel, shuah, linux-kernel-mentees

On Tue, Jul 1, 2025 at 12:38 PM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 6/23/25 12:47, I Hsin Cheng wrote:
> > According to the report of Coverity Scan [1], "sync_file" is going to be
> > NULL when entering the "if" section after "out_post_unlock", so
> > "fput(sync_file->file)" is never going to be exected in this block.
> >
> > [1]: https://scan5.scan.coverity.com/#/project-view/10074/10063?selectedIssue=1655089
> > Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
> > ---
> >   drivers/gpu/drm/msm/msm_gem_submit.c | 2 --
> >   1 file changed, 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
> > index d4f71bb54e84..cba1dc6fe6c6 100644
> > --- a/drivers/gpu/drm/msm/msm_gem_submit.c
> > +++ b/drivers/gpu/drm/msm/msm_gem_submit.c
> > @@ -904,8 +904,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
> >   out_post_unlock:
> >       if (ret && (out_fence_fd >= 0)) {
> >               put_unused_fd(out_fence_fd);
> > -             if (sync_file)
> > -                     fput(sync_file->file);
>
> Are you sure you want delete these two lines? It might not make
> sense to check sync_file inside if (ret && (out_fence_fd >= 0)),
> but it is ncecessary to fput.

fwiw, there is at least about to be a code path where this error
handling is not dead, once the VM_BIND series is merged

BR,
-R

> >       }
> >
> >       if (!IS_ERR_OR_NULL(submit)) {
>
> Check the error paths carefully to see if this is indeed the right fix.
>
> thanks,
> -- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-01 20:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23 18:47 [RFC PATCH] drm/msm: Remove dead code in msm_ioctl_gem_submit() I Hsin Cheng
2025-07-01 19:38 ` Shuah Khan
2025-07-01 20:08   ` Rob Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).