RE: [PATCH v10 14/14] dmaengine: idxd: Add support for device/wq defaults

From: Yu, Fenghua
Date: Wed Nov 29 2023 - 19:31:20 EST


Hi, Tom,

> From: Tom Zanussi <tom.zanussi@xxxxxxxxxxxxxxx>
> > > +       /* set name to "iaa_crypto" */
> > > +       memset(wq->name, 0, WQ_NAME_SIZE + 1);
> > > +       strscpy(wq->name, "iaa_crypto", WQ_NAME_SIZE + 1);
> >
> > Is strcpy(wq->name, "iaa_crypto") simpler than memset() and strscpy()?
>
> That's what I originally had, but checkpatch complained about it, suggesting
> strscpy, so I changed it to make checkpatch happy.

Why is size WQ_NAME_SIZE+1 instead of WQ_NAME_SIZE? Will WQ_NAME_SIZE+1 cause mem corruption because wq->name is defined as a string with WQ_NAME_SIZE?
>
> >
> > > +
> > > +       /* set driver_name to "crypto" */
> > > +       memset(wq->driver_name, 0, DRIVER_NAME_SIZE + 1);
> > > +       strscpy(wq->driver_name, "crypto", DRIVER_NAME_SIZE + 1);
> >
> > Is strcpy(wq->driver_name, "crypto") simpler?
>
> Same here.

Ditto.

Thanks.

-Fenghua