Re: [bug report] media: rcar-vin: add group allocator functions

2018-05-03 Thread Niklas Söderlund
Hi Dan,

Thanks for your report. A proposed fix to this is available [1], 
awaiting inclusion in the media-tree :-)

1. https://patchwork.linuxtv.org/patch/49025/

On 2018-05-03 15:36:30 +0300, Dan Carpenter wrote:
> Hello Niklas Söderlund,
> 
> The patch 3bb4c3bc85bf: "media: rcar-vin: add group allocator
> functions" from Apr 14, 2018, leads to the following static checker
> warning:
> 
>   drivers/media/platform/rcar-vin/rcar-core.c:346 rvin_group_put()
>   error: potential NULL dereference 'vin->group'.
> 
> drivers/media/platform/rcar-vin/rcar-core.c
>339  static void rvin_group_put(struct rvin_dev *vin)
>340  {
>341  mutex_lock(>group->lock);
>342  
>343  vin->group = NULL;
> ^
> Set to NULL.
> 
>344  vin->v4l2_dev.mdev = NULL;
>345  
>346  if (WARN_ON(vin->group->vin[vin->id] != vin))
> 
>347  goto out;
>348  
>349  vin->group->vin[vin->id] = NULL;
> 
>350  out:
>351  mutex_unlock(>group->lock);
>   
>352  
>353  kref_put(>group->refcount, rvin_group_release);
>   
> 
> There are a bunch of NULL dereferences here...
> 
>354  }
> 
> regards,
> dan carpenter

-- 
Regards,
Niklas Söderlund


[bug report] media: rcar-vin: add group allocator functions

2018-05-03 Thread Dan Carpenter
Hello Niklas Söderlund,

The patch 3bb4c3bc85bf: "media: rcar-vin: add group allocator
functions" from Apr 14, 2018, leads to the following static checker
warning:

drivers/media/platform/rcar-vin/rcar-core.c:346 rvin_group_put()
error: potential NULL dereference 'vin->group'.

drivers/media/platform/rcar-vin/rcar-core.c
   339  static void rvin_group_put(struct rvin_dev *vin)
   340  {
   341  mutex_lock(>group->lock);
   342  
   343  vin->group = NULL;
^
Set to NULL.

   344  vin->v4l2_dev.mdev = NULL;
   345  
   346  if (WARN_ON(vin->group->vin[vin->id] != vin))

   347  goto out;
   348  
   349  vin->group->vin[vin->id] = NULL;

   350  out:
   351  mutex_unlock(>group->lock);
  
   352  
   353  kref_put(>group->refcount, rvin_group_release);
  

There are a bunch of NULL dereferences here...

   354  }

regards,
dan carpenter