Re: [PATCH] staging: comedi: ni_mio_common: protect register write overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 02, 2018 at 07:24:32PM -0600, Spencer Olson wrote:
> On Tue, Oct 2, 2018 at 6:16 PM Spencer Olson <olsonse@xxxxxxxxx> wrote:
> >
> > On Tue, Oct 2, 2018 at 11:32 AM Greg Kroah-Hartman
> > <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> > >
> > > On Wed, Sep 19, 2018 at 10:17:19AM -0600, Spencer E. Olson wrote:
> > > > Fixes two problems introduced as early as
> > > > commit 03aef4b6dc12  ("Staging: comedi: add ni_mio_common code"):
> > > > (1) Ensures that the last four bits of NISTC_RTSI_TRIGB_OUT_REG register is
> > > >     not unduly overwritten on e-series devices.  On e-series devices, the
> > > >     first three of the last four bits are reserved.  The last bit defines
> > > >     the output selection of the RGOUT0 pin, otherwise known as
> > > >     RTSI_Sub_Selection.  For m-series devices, these last four bits are
> > > >     indeed used as the output selection of the RTSI7 pin (and the
> > > >     RTSI_Sub_Selection bit for the RGOUT0 pin is moved to the
> > > >     RTSI_Trig_Direction register.
> > > > (2) Allows all 4 RTSI_BRD lines to be treated as valid sources for RTSI
> > > >     lines.
> > > >
> > > > This patch also cleans up the ni_get_rtsi_routing command for readability.
> > > >
> > > > Fixes: 03aef4b6dc12  ("Staging: comedi: add ni_mio_common code")
> > > > Signed-off-by: Spencer E. Olson <olsonse@xxxxxxxxx>
> > > > Reviewed-by: Ian Abbott <abbotti@xxxxxxxxx>
> > > > Cc: stable <stable@xxxxxxxxxxxxxxx>
> > > > ---
> > > > I thought I had already submitted this patch a while ago...  Whoops.
> > > >  .../staging/comedi/drivers/ni_mio_common.c    | 24 +++++++++++++------
> > > >  1 file changed, 17 insertions(+), 7 deletions(-)
> > > >
> > > > diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
> > > > index 4dee2fc37aed..4d0d0621780e 100644
> > > > --- a/drivers/staging/comedi/drivers/ni_mio_common.c
> > > > +++ b/drivers/staging/comedi/drivers/ni_mio_common.c
> > > > @@ -4980,7 +4980,10 @@ static int ni_valid_rtsi_output_source(struct comedi_device *dev,
> > > >       case NI_RTSI_OUTPUT_G_SRC0:
> > > >       case NI_RTSI_OUTPUT_G_GATE0:
> > > >       case NI_RTSI_OUTPUT_RGOUT0:
> > > > -     case NI_RTSI_OUTPUT_RTSI_BRD_0:
> > > > +     case NI_RTSI_OUTPUT_RTSI_BRD(0):
> > > > +     case NI_RTSI_OUTPUT_RTSI_BRD(1):
> > > > +     case NI_RTSI_OUTPUT_RTSI_BRD(2):
> > > > +     case NI_RTSI_OUTPUT_RTSI_BRD(3):
> > > >               return 1;
> > > >       case NI_RTSI_OUTPUT_RTSI_OSC:
> > > >               return (devpriv->is_m_series) ? 1 : 0;
> > > > @@ -5001,11 +5004,18 @@ static int ni_set_rtsi_routing(struct comedi_device *dev,
> > > >               devpriv->rtsi_trig_a_output_reg |= NISTC_RTSI_TRIG(chan, src);
> > > >               ni_stc_writew(dev, devpriv->rtsi_trig_a_output_reg,
> > > >                             NISTC_RTSI_TRIGA_OUT_REG);
> > > > -     } else if (chan < 8) {
> > > > +     } else if (chan < NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) {
> > > >               devpriv->rtsi_trig_b_output_reg &= ~NISTC_RTSI_TRIG_MASK(chan);
> > > >               devpriv->rtsi_trig_b_output_reg |= NISTC_RTSI_TRIG(chan, src);
> > > >               ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
> > > >                             NISTC_RTSI_TRIGB_OUT_REG);
> > > > +     } else if (chan != NISTC_RTSI_TRIG_OLD_CLK_CHAN) {
> > > > +             /* probably should never reach this, since the
> > > > +              * ni_valid_rtsi_output_source above errors out if chan is too
> > > > +              * high
> > > > +              */
> > > > +             dev_err(dev->class_dev, "%s: unknown rtsi channel\n", __func__);
> > >
> > > This patch breaks the build very badly.  Always test-build your patches
> > > at the very least :(
> > >
> > > greg k-h
> >
> > I have been test building this with at least a fairly recent
> > staging-next rebase (rebase a week or two ago).  I'll rebase again and
> > check this out....
> 
> So the problem had been that I had been compiling the entire time with
> my other patch set that I recently have just submitted.  When I split
> this patch off from that patch set, I had neglected to compile with it
> by itsself.  The issue was a forgotten "{" at the beginning of the
> last if statement.

Each patch has to be self-contained to not break the build :(

> Should I resubmit this patch and the entire patch set from earlier
> today, each separately?

This patch needed to be applied separately as it fixed a bug that needed
to be backported to the stable kernels, right?  So for that, I need a
single patch that works :)

If your other patches then depend on this patch being applied (which is
fine), you should rebase your other series on top of it and resend them.

> The patch set from today titled "device-global identifiers and routes
> introduced" _does_ depend on this patch that was missing the
> brace--this is indicated in the patch notes as requested by Ian.

Ok, good, so all is fine.  If you fix up this patch.

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux