diff mbox series

[next] drm/i915: Fix NULL vs IS_ERR() check in __shmem_writeback()

Message ID 7f99a56b-d517-40b0-92b7-421c4fd813f2@stanley.mountain (mailing list archive)
State New, archived
Headers show
Series [next] drm/i915: Fix NULL vs IS_ERR() check in __shmem_writeback() | expand

Commit Message

Dan Carpenter Feb. 6, 2025, 8:17 a.m. UTC
The filemap_lock_folio() function doesn't return NULL, it returns error
pointers.

Fixes: 25dd342f0cc8 ("drm/i915/gem: convert __shmem_writeback() to folios")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andi Shyti Feb. 6, 2025, 11:16 a.m. UTC | #1
> The filemap_lock_folio() function doesn't return NULL, it returns error
> pointers.
> 
> Fixes: 25dd342f0cc8 ("drm/i915/gem: convert __shmem_writeback() to folios")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

...

>  		struct folio *folio;
>  
>  		folio = filemap_lock_folio(mapping, i);
> -		if (!folio)
> +		if (IS_ERR(folio))

ops! Thanks, Dan

Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>

Andi
Andi Shyti Feb. 7, 2025, 11:02 a.m. UTC | #2
Hi Dan,

On Thu, Feb 06, 2025 at 11:17:02AM +0300, Dan Carpenter wrote:
> The filemap_lock_folio() function doesn't return NULL, it returns error
> pointers.
> 
> Fixes: 25dd342f0cc8 ("drm/i915/gem: convert __shmem_writeback() to folios")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> index a784fb44e59c..fb263b421958 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> @@ -319,7 +319,7 @@ void __shmem_writeback(size_t size, struct address_space *mapping)
>  		struct folio *folio;
>  
>  		folio = filemap_lock_folio(mapping, i);
> -		if (!folio)
> +		if (IS_ERR(folio))

I don't see this patch yet in -next yet (and of course not in
drm-tip), which branch is it based on?

Thanks,
Andi

>  			continue;
>  
>  		if (!folio_mapped(folio) && folio_clear_dirty_for_io(folio)) {
> -- 
> 2.47.2
Andi Shyti Feb. 7, 2025, 11:04 a.m. UTC | #3
> > -		if (!folio)
> > +		if (IS_ERR(folio))
> 
> I don't see this patch yet in -next yet (and of course not in
> drm-tip), which branch is it based on?

To be precise, not this patch, but the patch(*) that this is fixing :-)

Andi

(*) "drm/i915/gem: Convert __shmem_writeback() to folios" from
Kirill
Dan Carpenter Feb. 7, 2025, 11:48 a.m. UTC | #4
On Fri, Feb 07, 2025 at 12:02:43PM +0100, Andi Shyti wrote:
> Hi Dan,
> 
> On Thu, Feb 06, 2025 at 11:17:02AM +0300, Dan Carpenter wrote:
> > The filemap_lock_folio() function doesn't return NULL, it returns error
> > pointers.
> > 
> > Fixes: 25dd342f0cc8 ("drm/i915/gem: convert __shmem_writeback() to folios")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> >  drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > index a784fb44e59c..fb263b421958 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > @@ -319,7 +319,7 @@ void __shmem_writeback(size_t size, struct address_space *mapping)
> >  		struct folio *folio;
> >  
> >  		folio = filemap_lock_folio(mapping, i);
> > -		if (!folio)
> > +		if (IS_ERR(folio))
> 
> I don't see this patch yet in -next yet (and of course not in
> drm-tip), which branch is it based on?
> 

This was in linux-next but it's not there now.  It came via -mm.  I
guess it's been dropped and Kirill will fix this in his devel branch
before resending.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
index a784fb44e59c..fb263b421958 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
@@ -319,7 +319,7 @@  void __shmem_writeback(size_t size, struct address_space *mapping)
 		struct folio *folio;
 
 		folio = filemap_lock_folio(mapping, i);
-		if (!folio)
+		if (IS_ERR(folio))
 			continue;
 
 		if (!folio_mapped(folio) && folio_clear_dirty_for_io(folio)) {