From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751677AbdBSTx0 (ORCPT ); Sun, 19 Feb 2017 14:53:26 -0500 Received: from mail-db5eur01on0085.outbound.protection.outlook.com ([104.47.2.85]:14944 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751067AbdBSTxY (ORCPT ); Sun, 19 Feb 2017 14:53:24 -0500 From: Majd Dibbiny To: SF Markus Elfring CC: "linux-rdma@vger.kernel.org" , Doug Ledford , Hal Rosenstock , "Leon Romanovsky" , Matan Barak , "Sean Hefty" , Yishai Hadas , LKML , "kernel-janitors@vger.kernel.org" Subject: Re: [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() Thread-Topic: [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() Thread-Index: AQHSiiu/Wcd/FFRP8kCn8A+4wrbJoKFwv0pa Date: Sun, 19 Feb 2017 19:53:18 +0000 Message-ID: <63C7B48F-BC28-4ADF-BF97-6E22B2F1D80D@mellanox.com> References: <1935365a-bd7c-461e-6a84-0c5d3a501fff@users.sourceforge.net>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=majd@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [46.121.82.152] x-ms-office365-filtering-correlation-id: d6681b81-fbcd-4bc1-60c9-08d45900f398 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:AM4PR05MB1729; x-microsoft-exchange-diagnostics: 1;AM4PR05MB1729;7:3UJwMW6siqZZWe94/jeTkUIatqiHKHmhE1mj0HhlUUSy/u8Ik+U4fOXFJ2ScBfrCZIqZVyEVSAoGhRdHwdpmOsXXtJrbCscukiSPn1/tD8CC+WxDh3hM1p2Qzq+bRud2U14tV7HUU9uHw7b7otUC2PYvA9vm5mqP+o514+r+v59MvOO1Jcl+WXymg3I9jn1wAJxtxud6j+lJBVRmjY5b+eB9kv7pJGSZVO37fhQpCxpgtdJpht0flNDtLh+noiOLoh7SwmDN3JyV4EvmedYDwxheeV2bf1YRj2/qF9FeyligGU4OMItPBr+Bx0V+J+meWrsb39nyaV+j7tOUhjjkLQ== x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(788757137089)(42262312472803); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123558025)(20161123564025)(20161123555025)(20161123562025)(6072148);SRVR:AM4PR05MB1729;BCL:0;PCL:0;RULEID:;SRVR:AM4PR05MB1729; x-forefront-prvs: 02234DBFF6 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(39450400003)(39850400002)(39840400002)(39410400002)(189002)(377454003)(199003)(24454002)(86362001)(66066001)(82746002)(4326007)(6436002)(3660700001)(77096006)(105586002)(53936002)(2906002)(6246003)(97736004)(6506006)(122556002)(38730400002)(3280700002)(83716003)(25786008)(39060400002)(189998001)(966004)(6486002)(110136004)(229853002)(8936002)(102836003)(3846002)(36756003)(8676002)(6512007)(5660300001)(106116001)(6116002)(92566002)(81156014)(2900100001)(6916009)(2950100002)(33656002)(101416001)(305945005)(68736007)(76176999)(50986999)(81166006)(7736002)(54356999)(54906002)(99286003)(6306002)(106356001)(104396002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR05MB1729;H:DB6PR0501MB2072.eurprd05.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Feb 2017 19:53:18.5232 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB1729 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v1JJrZQp005784 > On Feb 18, 2017, at 11:12 PM, SF Markus Elfring wrote: > > From: Markus Elfring > Date: Sat, 18 Feb 2017 16:56:52 +0100 > > * A multiplication for the size determination of a memory allocation > indicated that an array data structure should be processed. > Thus use the corresponding function "kmalloc_array". > > 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 > --- > drivers/infiniband/hw/mlx4/qp.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c > index 7d76f769233c..11fec4a8fae5 100644 > --- a/drivers/infiniband/hw/mlx4/qp.c > +++ b/drivers/infiniband/hw/mlx4/qp.c > @@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp) > { > int i; > > - qp->sqp_proxy_rcv = > - kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt, > - GFP_KERNEL); > + qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt, > + sizeof(*qp->sqp_proxy_rcv), > + GFP_KERNEL); > if (!qp->sqp_proxy_rcv) > return -ENOMEM; > for (i = 0; i < qp->rq.wqe_cnt; i++) { > -- > 2.11.1 > > -- > 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 Thanks, Reviewed-by: Majd Dibbiny