Skip to content

Commit

Permalink
staging: comedi: comedi_parport: Use 16-bit 0 for interrupt data
Browse files Browse the repository at this point in the history
The comedi_parport driver has an "interrupt" subdevice that supports
Comedi asynchronous commands, placing a value in the Comedi buffer for
each interrupt.  The subdevice uses Comedi's 16-bit sample format but
the interrupt handler is calling `comedi_buf_write_samples()` with the
address of a 32-bit integer `&s->state`.  On bigendian machines, this
will copy 2 bytes from the wrong end of the 32-bit integer.  This isn't
really a problem since `s->state` will always be 0 for this subdevice,
but clean it up by using a 16-bit variable initialized to 0 to pass the
value.

Signed-off-by: Ian Abbott <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ian-abbott authored and gregkh committed Mar 10, 2021
1 parent 8536749 commit a1acdbc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/staging/comedi/drivers/comedi_parport.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,13 @@ static irqreturn_t parport_interrupt(int irq, void *d)
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
unsigned int ctrl;
unsigned short val = 0;

ctrl = inb(dev->iobase + PARPORT_CTRL_REG);
if (!(ctrl & PARPORT_CTRL_IRQ_ENA))
return IRQ_NONE;

comedi_buf_write_samples(s, &s->state, 1);
comedi_buf_write_samples(s, &val, 1);
comedi_handle_events(dev, s);

return IRQ_HANDLED;
Expand Down

0 comments on commit a1acdbc

Please sign in to comment.