From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D60BC43381 for ; Tue, 26 Feb 2019 08:48:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D83F92147C for ; Tue, 26 Feb 2019 08:48:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727291AbfBZIso (ORCPT ); Tue, 26 Feb 2019 03:48:44 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:51439 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbfBZIso (ORCPT ); Tue, 26 Feb 2019 03:48:44 -0500 Received: from marcel-macpro.fritz.box (p4FF9F361.dip0.t-ipconnect.de [79.249.243.97]) by mail.holtmann.org (Postfix) with ESMTPSA id D7459CF2A3; Tue, 26 Feb 2019 09:56:36 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH][next] Bluetooth: mgmt: Use struct_size() helper From: Marcel Holtmann In-Reply-To: <20190225191137.GA24383@embeddedor> Date: Tue, 26 Feb 2019 09:48:41 +0100 Cc: Johan Hedberg , "David S. Miller" , "open list:BLUETOOTH DRIVERS" , netdev , linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: References: <20190225191137.GA24383@embeddedor> To: "Gustavo A. R. Silva" X-Mailer: Apple Mail (2.3445.102.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gustavo, > Make use of the struct_size() helper instead of an open-coded version > in order to avoid any potential type mistakes, in particular in the > context in which this code is being used. > > So, change the following form: > > sizeof(*rp) + (sizeof(rp->entry[0]) * count); > > to : > > struct_size(rp, entry, count) > > Notice that, in this case, variable rp_len is not necessary, hence > it is removed. > > This code was detected with the help of Coccinelle. > > Signed-off-by: Gustavo A. R. Silva > --- > net/bluetooth/mgmt.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel