Message ID | 5e5e00d3-b6a4-7371-65be-c5fe387d26b3@users.sourceforge.net (mailing list archive) |
---|---|
State | Deferred |
Headers | show |
On Wed, Apr 05, 2017 at 03:51:52PM +0200, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Wed, 5 Apr 2017 09:43:54 +0200 > > * A multiplication for the size determination of a memory allocation > indicated that an array data structure should be processed. > Thus use the corresponding function "kcalloc". > > This issue was detected by using the Coccinelle software. > > * Replace the specification of a data structure by a pointer dereference > to make the corresponding size determination a bit safer according to > the Linux coding style convention. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > drivers/infiniband/hw/qib/qib_iba7322.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c > index af9f596bb68b..e4e4e675c89c 100644 > --- a/drivers/infiniband/hw/qib/qib_iba7322.c > +++ b/drivers/infiniband/hw/qib/qib_iba7322.c > @@ -7324,8 +7324,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, > actual_cnt -= dd->num_pports; > > tabsize = actual_cnt; > - dd->cspec->msix_entries = kzalloc(tabsize * > - sizeof(struct qib_msix_entry), GFP_KERNEL); > + dd->cspec->msix_entries = kcalloc(tabsize, > + sizeof(*dd->cspec->msix_entries), > + GFP_KERNEL); Are we fine with loosing the zeroing of the entries? > if (!dd->cspec->msix_entries) > tabsize = 0; > > -- > 2.12.2 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
>> @@ -7324,8 +7324,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, >> actual_cnt -= dd->num_pports; >> >> tabsize = actual_cnt; >> - dd->cspec->msix_entries = kzalloc(tabsize * >> - sizeof(struct qib_msix_entry), GFP_KERNEL); >> + dd->cspec->msix_entries = kcalloc(tabsize, >> + sizeof(*dd->cspec->msix_entries), >> + GFP_KERNEL); > > Are we fine with loosing the zeroing of the entries? How did you get this concern? Do you really miss such functionality from the other interface? Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Apr 05, 2017 at 04:54:40PM +0200, SF Markus Elfring wrote: > >> @@ -7324,8 +7324,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, > >> actual_cnt -= dd->num_pports; > >> > >> tabsize = actual_cnt; > >> - dd->cspec->msix_entries = kzalloc(tabsize * > >> - sizeof(struct qib_msix_entry), GFP_KERNEL); > >> + dd->cspec->msix_entries = kcalloc(tabsize, > >> + sizeof(*dd->cspec->msix_entries), > >> + GFP_KERNEL); > > > > Are we fine with loosing the zeroing of the entries? > > How did you get this concern? > > Do you really miss such functionality from the other interface? Ahm... Don't kzalloc() and kcalloc() both pass in __GFP_ZERO?
On Wed, Apr 05, 2017 at 05:06:58PM +0200, Johannes Thumshirn wrote: > On Wed, Apr 05, 2017 at 04:54:40PM +0200, SF Markus Elfring wrote: > > >> @@ -7324,8 +7324,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, > > >> actual_cnt -= dd->num_pports; > > >> > > >> tabsize = actual_cnt; > > >> - dd->cspec->msix_entries = kzalloc(tabsize * > > >> - sizeof(struct qib_msix_entry), GFP_KERNEL); > > >> + dd->cspec->msix_entries = kcalloc(tabsize, > > >> + sizeof(*dd->cspec->msix_entries), > > >> + GFP_KERNEL); > > > > > > Are we fine with loosing the zeroing of the entries? > > > > How did you get this concern? > > > > Do you really miss such functionality from the other interface? > > Ahm... Don't kzalloc() and kcalloc() both pass in __GFP_ZERO? Yes. Please ignore my comment. > > -- > Johannes Thumshirn Storage > jthumshirn@suse.de +49 911 74053 689 > SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg > GF: Felix Imendörffer, Jane Smithard, Graham Norton > HRB 21284 (AG Nürnberg) > Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index af9f596bb68b..e4e4e675c89c 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c @@ -7324,8 +7324,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, actual_cnt -= dd->num_pports; tabsize = actual_cnt; - dd->cspec->msix_entries = kzalloc(tabsize * - sizeof(struct qib_msix_entry), GFP_KERNEL); + dd->cspec->msix_entries = kcalloc(tabsize, + sizeof(*dd->cspec->msix_entries), + GFP_KERNEL); if (!dd->cspec->msix_entries) tabsize = 0;