Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp2826715imc; Sat, 23 Feb 2019 12:06:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IZs6hu+9YS0oEltK5qpFJo2QW4Zf6GhWrzLtOLU4RQsMPycSpC6x8n43qP3xX8D8QREx7uK X-Received: by 2002:a17:902:8346:: with SMTP id z6mr11021459pln.74.1550952391600; Sat, 23 Feb 2019 12:06:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550952391; cv=none; d=google.com; s=arc-20160816; b=azLQLY+w+7X5yffEwPnVKMQiJpnBZUmS1wO5ESCsTkI0++CjzX1lwOYEN5cLtpeSrT 9Kom5pHPiEL+NjH6wSn3Pr4mnX9MmQUZ5pZjrMVkg69R9UzzA0gSFSqX/sjliPwXUPNy 69SgS8eiO/Bbg34TRFo+fhHsxgtO7U8SvCkr5yjq1Ps8NPE/El0hMay50vbWmV/5rbdX +Iz9QatIJIXUYQ/rIfK8s/ynK4N7q3U8CNBX7WjgCR1trRrGl4QXAj22h9U4C8vcXo+Y 8D+j57ukCdvKe3AlBLJ52aGY7YHUeAPg/gVBfRxSkmS/gCtLdZ0ssSXB786vPcM4q2Hz RkAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=uSqMe+A9OnhNsyQbje7WkP90ukd6KF2cqCWyujObDL8=; b=XhiNhUcpV42ujPadVv8tymtgK1KG4PSvA2hJBoegqPlzbgUeKJEdJG+Nf8/kVd5EGj 1ajY24YG3BxgkXNurQVGbIplalFyPlmbKjV/jjqd/qkXOvh+vMPj7i5FQW2bJd5qA0R+ Jc1P/GUI6n3Zbpc+cX5f8syES9ilUxa3x14L7BQ6IVSdX5qsCjl5AqDPFy2H/7HHGabC tPEwTy/7nN5zYV5F/fPfYuBceDR6RSqAGpW4U5anRKGfsiu9PLgLmWxnTbhioW0KqNHT hc+HTlWzNLtoQ1TUs5Q1l7FcosKm5eMfhlA/FW2pgYKfxMMKDIYFlBfkgViMMoGabS9v higA== ARC-Authentication-Results: i=1; mx.google.com; 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 h6si4200819pgs.211.2019.02.23.12.06.15; Sat, 23 Feb 2019 12:06:31 -0800 (PST) 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; 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 S1728217AbfBWUFz (ORCPT + 99 others); Sat, 23 Feb 2019 15:05:55 -0500 Received: from smtprelay0212.hostedemail.com ([216.40.44.212]:45567 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726089AbfBWUFz (ORCPT ); Sat, 23 Feb 2019 15:05:55 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id C829C180192C0; Sat, 23 Feb 2019 20:05:53 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:599:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:2895:2919:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3874:4321:5007:10004:10400:10848:11026:11232:11658:11914:12048:12109:12296:12663:12740:12760:12895:13069:13161:13229:13311:13357:13439:14659:14721:21080:21611:21627:21740:30012:30054:30070:30091,0,RBL:47.151.153.53:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: north74_334fca11f0f44 X-Filterd-Recvd-Size: 1872 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA; Sat, 23 Feb 2019 20:05:52 +0000 (UTC) Message-ID: Subject: Re: [PATCH] nvmet-fc: use zero-sized array and struct_size() in kzalloc() From: Joe Perches To: "Gustavo A. R. Silva" , James Smart , Christoph Hellwig , Sagi Grimberg Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Date: Sat, 23 Feb 2019 12:05:50 -0800 In-Reply-To: <20190223185108.GA6706@embeddedor> References: <20190223185108.GA6706@embeddedor> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2019-02-23 at 12:51 -0600, Gustavo A. R. Silva wrote: > Update the code to use a zero-sized array instead of a pointer in > structure nvmet_fc_tgt_queue and use struct_size() in kzalloc(). [] > This code was detected with the help of Coccinelle. Really? Impressive script that found this one. > diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c [] > @@ -128,12 +128,12 @@ struct nvmet_fc_tgt_queue { > struct nvmet_cq nvme_cq; > struct nvmet_sq nvme_sq; > struct nvmet_fc_tgt_assoc *assoc; > - struct nvmet_fc_fcp_iod *fod; /* array of fcp_iods */ > struct list_head fod_list; > struct list_head pending_cmd_list; > struct list_head avail_defer_list; > struct workqueue_struct *work_q; > struct kref ref; > + struct nvmet_fc_fcp_iod fod[]; /* array of fcp_iods */ > } __aligned(sizeof(unsigned long long)); Moving a pointer from the middle of a struct to the end seems unusual for coccinelle.