All of lore.kernel.org
 help / color / mirror / Atom feed
* re: staging:iio:triggers introduce iio_trigger_ops to take const bits out of iio_trig_structure.
@ 2016-05-10  8:03 Dan Carpenter
  2016-05-14 17:21 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-05-10  8:03 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio

Hello Jonathan Cameron,

The patch d29f73db7910: "staging:iio:triggers introduce
iio_trigger_ops to take const bits out of iio_trig_structure." from
Aug 12, 2011, leads to the following static checker warning:

	drivers/iio/industrialio-trigger.c:376 iio_trigger_write_current()
	error: we previously assumed 'indio_dev->trig->ops' could be null (see line 367)

drivers/iio/industrialio-trigger.c
   360  
   361          if (trig && trig->ops && trig->ops->validate_device) {
                            ^^^^^^^^^
New check.

   362                  ret = trig->ops->validate_device(trig, indio_dev);
   363                  if (ret)
   364                          return ret;
   365          }
   366  
   367          indio_dev->trig = trig;
   368  
   369          if (oldtrig) {
   370                  if (indio_dev->modes & INDIO_EVENT_TRIGGERED)
   371                          iio_trigger_detach_poll_func(oldtrig,
   372                                                       indio_dev->pollfunc_event);
   373                  iio_trigger_put(oldtrig);
   374          }
   375          if (indio_dev->trig) {
   376                  iio_trigger_get(indio_dev->trig);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dereferenced inside the function without checking.

   377                  if (indio_dev->modes & INDIO_EVENT_TRIGGERED)
   378                          iio_trigger_attach_poll_func(indio_dev->trig,
   379                                                       indio_dev->pollfunc_event);
   380          }

regards,
dan carpenter

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

* Re: staging:iio:triggers introduce iio_trigger_ops to take const bits out of iio_trig_structure.
  2016-05-10  8:03 staging:iio:triggers introduce iio_trigger_ops to take const bits out of iio_trig_structure Dan Carpenter
@ 2016-05-14 17:21 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2016-05-14 17:21 UTC (permalink / raw)
  To: Dan Carpenter, jic23; +Cc: linux-iio

On 10/05/16 09:03, Dan Carpenter wrote:
> Hello Jonathan Cameron,
> 
> The patch d29f73db7910: "staging:iio:triggers introduce
> iio_trigger_ops to take const bits out of iio_trig_structure." from
> Aug 12, 2011, leads to the following static checker warning:
> 
> 	drivers/iio/industrialio-trigger.c:376 iio_trigger_write_current()
> 	error: we previously assumed 'indio_dev->trig->ops' could be null (see line 367)
> 
> drivers/iio/industrialio-trigger.c
>    360  
>    361          if (trig && trig->ops && trig->ops->validate_device) {
>                             ^^^^^^^^^
> New check.
> 
>    362                  ret = trig->ops->validate_device(trig, indio_dev);
>    363                  if (ret)
>    364                          return ret;
>    365          }
>    366  
>    367          indio_dev->trig = trig;
>    368  
>    369          if (oldtrig) {
>    370                  if (indio_dev->modes & INDIO_EVENT_TRIGGERED)
>    371                          iio_trigger_detach_poll_func(oldtrig,
>    372                                                       indio_dev->pollfunc_event);
>    373                  iio_trigger_put(oldtrig);
>    374          }
>    375          if (indio_dev->trig) {
>    376                  iio_trigger_get(indio_dev->trig);
>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Dereferenced inside the function without checking.
> 
>    377                  if (indio_dev->modes & INDIO_EVENT_TRIGGERED)
>    378                          iio_trigger_attach_poll_func(indio_dev->trig,
>    379                                                       indio_dev->pollfunc_event);
>    380          }
> 
Good point - trig->ops is not optional at all (exactly as it has the module handle).  
Not exactly a new issue but will good to clean it up at some point.

Funnily enough this exact question got raised recently and I foolishly though it
was just a documentation thing, whereas clearly quite a bit of the code in here
makes it 'look' optional when it never was.

We probably should sanity check and fault out in any attempt to register
a trigger without an ops structure though.

I'll put a patch together shortly to do this.

Jonathan
> regards,
> dan carpenter
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

end of thread, other threads:[~2016-05-14 17:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-10  8:03 staging:iio:triggers introduce iio_trigger_ops to take const bits out of iio_trig_structure Dan Carpenter
2016-05-14 17:21 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.