Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1215847yba; Thu, 4 Apr 2019 06:34:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqrE2yDqyZF+5yjbaR1y840k9K0d1Zy4kvyhG8yz12dqAU2nWrK4mak11vf49pgktB6gu7 X-Received: by 2002:a62:1e06:: with SMTP id e6mr5975045pfe.168.1554384843194; Thu, 04 Apr 2019 06:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554384843; cv=none; d=google.com; s=arc-20160816; b=oCiyRAX3A9EVtDoygtIkwsnjTW9RMuPzK/HdEgbDLXNdyG1iZk/CSeCg/DmDbP5Zet DDooBaynewJ/ZlQ8ydgDR+KYDqNUciZWyZ/Ihbte58Q7hP7mTkuJyjT5faYZac0qCvh2 APrXwhZ4qaO8+Lso8i3ENpxMmn3jJv4EoxfOzIrgqn3of7bduvbgPwyuf7pB8sTCzNwy 25CBhoTAxirEreXqpKycGGq7223A+Qc8APWfmzXh1X1lgomSZXV5Fh4BTCuNT0997QFa 6HRn+5pE7yu5UNIacQwMAXnenjB0XEbu6zadC2exf8Jb7dRkcecxXcPPPnkybhKNJpZ4 X/vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=krEZKDAnezyPjEgf3rWaGq6ir146IFxLTl46GJh79+k=; b=dfVNMSMoC+gtN7k0BlZDE6NZ/92CWOmAhbHEtvT4UgR9OMYk4MlcYH/uShilVctZuG DREziRYpqDbd760ILNw7pXy+kGQaSMmMC2P/wi5XJUGOUo+zrbeNjk8Ka+IIADDNa7mD hkK7n2DnZ7MHmdAF70Iua60tkq9nlK47MSz8mZF4FiG5Xesa+G+xamkpd8h2lem8ecsB M7UwEO9A7SvrW/nUPlPWtLoTgk4Do0xpTB9LtbesPDVaBw3mXqV5Z5qja8P4TYKABGp0 oo961per7bL6v3mnOMN4nWgt3u88tCW8O26PoScjrSD8f5MuWrmmGC+PJq/9iRLthuv6 kqmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quantenna.com header.s=selector2 header.b=O8+zmoN6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si16222166pgk.320.2019.04.04.06.33.47; Thu, 04 Apr 2019 06:34:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@quantenna.com header.s=selector2 header.b=O8+zmoN6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729122AbfDDNdD (ORCPT + 99 others); Thu, 4 Apr 2019 09:33:03 -0400 Received: from mail-eopbgr740078.outbound.protection.outlook.com ([40.107.74.78]:23794 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726269AbfDDNdD (ORCPT ); Thu, 4 Apr 2019 09:33:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=krEZKDAnezyPjEgf3rWaGq6ir146IFxLTl46GJh79+k=; b=O8+zmoN6C3URrZms6wykcsRuQH7tN3kJpbUR6wXyNRVClu0mds4X5N/9hy3fWk0XnO5OydzTja/khhUtGhPcVEKlrNoNYM58ck6+6AtGs2+B7gH32Iptx/YVSb/zTIUWAUFqqC10aYfJB7CLhF2E2Ufl2/99Qy2YqlDzEyCSGvk= Received: from DM6PR05MB6348.namprd05.prod.outlook.com (20.178.224.143) by DM6PR05MB4812.namprd05.prod.outlook.com (20.176.111.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.7; Thu, 4 Apr 2019 13:33:00 +0000 Received: from DM6PR05MB6348.namprd05.prod.outlook.com ([fe80::f485:e463:a00:e884]) by DM6PR05MB6348.namprd05.prod.outlook.com ([fe80::f485:e463:a00:e884%3]) with mapi id 15.20.1771.007; Thu, 4 Apr 2019 13:33:00 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com (52.135.117.74) by SN6PR05MB4814.namprd05.prod.outlook.com (52.135.116.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.6; Thu, 4 Apr 2019 13:32:42 +0000 Received: from SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::ecfd:3a22:dcb3:3b9e]) by SN6PR05MB4928.namprd05.prod.outlook.com ([fe80::ecfd:3a22:dcb3:3b9e%4]) with mapi id 15.20.1771.007; Thu, 4 Apr 2019 13:32:42 +0000 From: Sergey Matyukevich To: "Gustavo A. R. Silva" CC: Igor Mitsyanko , Avinash Patil , Sergey Matyukevich , Kalle Valo , "David S. Miller" , "linux-wireless@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH][next] qtnfmac: replace qtnf_cmd_acl_data_size() with struct_size() Thread-Topic: [PATCH][next] qtnfmac: replace qtnf_cmd_acl_data_size() with struct_size() Thread-Index: AQHU6kVbVDZ121t/CEKyy1UYmGUKFqYsAS+A Date: Thu, 4 Apr 2019 13:32:42 +0000 Message-ID: <20190404133234.2uatru2vlw3ntrmv@bars> References: <20190403170236.GA31637@embeddedor> In-Reply-To: <20190403170236.GA31637@embeddedor> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR03CA0029.namprd03.prod.outlook.com (2603:10b6:a02:a8::42) To SN6PR05MB4928.namprd05.prod.outlook.com (2603:10b6:805:9d::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [195.182.157.78] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 311b6b1d-26d7-46ff-9b79-08d6b902036d x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(2017052603328)(7193020);SRVR:SN6PR05MB4814; x-ms-traffictypediagnostic: SN6PR05MB4814:|DM6PR05MB4812: x-moderation-data: 4/4/2019 1:32:58 PM x-microsoft-antispam-prvs: x-forefront-prvs: 0997523C40 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(7916004)(366004)(396003)(39850400004)(346002)(376002)(136003)(51914003)(189003)(199004)(66066001)(436003)(52116002)(2906002)(53936002)(54906003)(76176011)(11346002)(68736007)(446003)(6916009)(486006)(256004)(386003)(186003)(476003)(6506007)(102836004)(6246003)(316002)(6116002)(3846002)(26005)(33716001)(6512007)(99286004)(9686003)(6486002)(8936002)(305945005)(5660300002)(81166006)(71190400001)(229853002)(97736004)(71200400001)(7736002)(14454004)(105586002)(25786009)(81156014)(8676002)(86362001)(1076003)(4326008)(6436002)(478600001)(106356001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR05MB4812;H:DM6PR05MB6348.namprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2TMw65H55pyoLAu/8AT3RbjTfxtalgm++u2x4eOBn1HBvMG+6YY2iU64SrfGXUqGicMiXtmgKgsRHQD+n49ZoVrwEyiH6vigzdh7C6V9jC4jeGyKEYoSWm2pqnap8nyFM5SidE+CiOgY7AMDdNcftp9lNg2biYxReOpenJ7XcfoHrO3ZhO4+QDi++Vf/w9DsV8W5gtndBlDZf+Q4ggUXSSKGxPxIK9zHnV1pnj4mtB5/5pTtNhrP+oHIFroSn2uQaB+YwRjQAPOmmYFtixANV44NC9xKo4omZKGyuY+7VKPLGG+9xAH2Ysu35PDVEGeE4xY0mIvH1cPXe2OlBQB+NKf+z3OgvNYYODw6rkRgLzDJNwYZlyetKMhA6OMVdroSOskUQRWir03cmfL4xLnVF1CAVhTVIXkj/U0SPeCr2Fo= Content-Type: text/plain; charset="us-ascii" Content-ID: <69A65985265894408D7C1D2371109492@namprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-Network-Message-Id: 311b6b1d-26d7-46ff-9b79-08d6b902036d X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Apr 2019 13:33:00.2196 (UTC) X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR05MB4812 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > One of the more common cases of allocation size calculations is finding > the size of a structure that has a zero-sized array at the end, along > with memory for some number of elements for that array. For example: >=20 > struct foo { > int stuff; > struct boo entry[]; > }; >=20 > size =3D sizeof(struct foo) + count * sizeof(struct boo); > instance =3D kzalloc(size, GFP_KERNEL) >=20 > Instead of leaving these open-coded and prone to type mistakes, we can > now use the new struct_size() helper: >=20 > size =3D struct_size(instance, entry, count); >=20 > or >=20 > instance =3D kzalloc(struct_size(instance, entry, count), GFP_KERNEL) >=20 > Based on the above, replace qtnf_cmd_acl_data_size() with the > new struct_size() helper. >=20 > This code was detected with the help of Coccinelle. >=20 > Signed-off-by: Gustavo A. R. Silva > --- > drivers/net/wireless/quantenna/qtnfmac/commands.c | 15 ++++----------- > 1 file changed, 4 insertions(+), 11 deletions(-) Hi Gustavo, Thanks for the patch! By the way, it does not apply cleanly, so it needs to be rebased on top of the up-to-date wireless-drivers-next tree. Let me know if you would prefer me to care about rebase. Then I will add this patch to the upcoming series of qtnfmac fixes. Reviewed-by: Sergey Matyukevich Regards, Sergey