Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2861150ybl; Thu, 29 Aug 2019 14:06:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1HMbF4jkN/VtljthcZkzNLW1URuEd1JiFGkwXNhpV5QzMeZH9mTLlkkLpJjyqs8WRUwgr X-Received: by 2002:a65:5c4b:: with SMTP id v11mr10220234pgr.62.1567112804833; Thu, 29 Aug 2019 14:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567112804; cv=none; d=google.com; s=arc-20160816; b=VP/r8GDq96jry0vk2xLquE9UaWhmR3WLoXc4i19S+Se3QAYeKLvoWFNRJTatwVpxnD CbbapzoyBop9OxECKK+yxnlzWIMsjZ9BsONzgveNmKMhR6Nr+XTm4Z7NQb3YOX6pcLBl vMty0RJN2cd+d1ckdJMHiNE2a8tEdo+xizzkhVKg0A3h7Y8iEgInF1BkMySUK3fGOYx9 JriDV6RL025lO9q3wJFWCy/TXeTAar1gmcwxkfQ04dgLEoLTq7iVehw24uxb8OAii3tZ tS6cXBlZ+l1aKzCTouEgPIocZg7tiAPD3YBzpbuQ25YA7o1Q8JPHXTWN/kNv/DSVC8Vv es1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zz/IcpIogQHwbVO/Egjox/eu8Ruvdetizg0QLnWTWdk=; b=rGM3gMHc12vk4t2BI6VI8VBxjzOs2TQLNKmT50tv4CbxJyU8j5nre31UTCdqgcxgGb BrA9SNAdHktR/wjUTpRtNJJsXdjdPmCOxIulmbegXoS40NI2f4QRFFf+oM8G/hB3KDQC PEl/QS/iJhw6ja8/kgg68+dMaMqERAC61wEUs5xOsQbZg3Xhqw84SakBRJTsCzi4XJOf StpHxumF/2gRsJA4WyTviZYcHzRWMR1HTUN013shdCVYEwb9yFrsUfdt6PTPvs5F5uq4 JNTUXmDuFHqqBQmEO1T90CU8TamT54ueNqxRD5BMEZOl/bva/jxvCb0lvXB38R5b8xXi TodA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=UDZgtwo0; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 80si2975464pgf.5.2019.08.29.14.06.28; Thu, 29 Aug 2019 14:06:44 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=UDZgtwo0; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727935AbfH2VFC (ORCPT + 99 others); Thu, 29 Aug 2019 17:05:02 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:32956 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbfH2VFC (ORCPT ); Thu, 29 Aug 2019 17:05:02 -0400 Received: by mail-ot1-f67.google.com with SMTP id p23so4888661oto.0 for ; Thu, 29 Aug 2019 14:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zz/IcpIogQHwbVO/Egjox/eu8Ruvdetizg0QLnWTWdk=; b=UDZgtwo0oFSbwbrZ20aRDIUOHVsOZ4QNSGS9i2xZYwSshsp9/Rx+od4w9K5/fI1EzL eEvX6n3R9d2FJVEF/ormhBdNO3FTcnJ99qUXUA0bDjdR3Gp9nMHV2syoniOtQtaYaS5Z MNrBmcnP1DaiX6cIsQXCAqc9cHw+47E4+lynszEsdDZgQMhRT18vNUKfnoOLNfWCJ3H6 otegJ/kpPCyGYA7EFiNveGSds+xkWRS2fdfac0KqCIZy2zD4yjAD0x7bgEPgjT9b3bz4 foAf/nd5dDoGc/34WbE2eWjhELAHjT4DjLyy0jbCfYxqLwBu7REDoKgzCC+NTu7a/XbV dc3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zz/IcpIogQHwbVO/Egjox/eu8Ruvdetizg0QLnWTWdk=; b=bifOVaKEDgxALPRYYtnTYuYB414CL+4LHqDzgADAQ80hhJQUkXm+brDKmOhx7MIQtn OxWa2MbVkp9KbdYZ/TXzo7+rQe57HwvVAst7QOwymQvz9eqdjjLYXKkPfTlBdD0WeeAh HQoyDqwPsggPRdc9iZfZLtC3RQ8FvsFhlT9/iWjKGN2HyV0oGoeV0lBQAsSYPZNiJvFM kalK/v7DnZHOzAP/Rm1IMg1MBq2eb+FrHRecu6b7/hbTl1J0dWlmgE+QT9WIijSSm9v8 cYro1DzAUcKT5bJNiICYZnDi3w2IYUGtS4d6MBoBy+bY6IBSQ05jiUXpWSIvkuL8GdWb aKRw== X-Gm-Message-State: APjAAAXawHTzX+bjYjS5Q96dn+24RwFMRWelsFT7I45lbZwa7mDva3TK Oxn2Lblej7ejNmVjGR2R+1g7x9SW0YRWkLMSG+3OAXtN X-Received: by 2002:a9d:6b96:: with SMTP id b22mr9855859otq.363.1567112701542; Thu, 29 Aug 2019 14:05:01 -0700 (PDT) MIME-Version: 1.0 References: <20190610210613.GA21989@embeddedor> <3e80b36c86942278ee66aebdd5ea2632f104083a.camel@intel.com> <7980d0c0b43bc6f377e0daad4a066f7ab37c2258.camel@intel.com> In-Reply-To: <7980d0c0b43bc6f377e0daad4a066f7ab37c2258.camel@intel.com> From: Dan Williams Date: Thu, 29 Aug 2019 14:04:49 -0700 Message-ID: Subject: Re: [PATCH] libnvdimm, region: Use struct_size() in kzalloc() To: "Verma, Vishal L" Cc: "Jiang, Dave" , "gustavo@embeddedor.com" , "Busch, Keith" , "Weiny, Ira" , "linux-kernel@vger.kernel.org" , "linux-nvdimm@lists.01.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 28, 2019 at 1:24 PM Verma, Vishal L wrote: > > On Wed, 2019-08-28 at 14:36 -0500, Gustavo A. R. Silva wrote: > > > struct_size() does not apply to those scenarios. See below... > > > > > [1]: > > > https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/tree/drivers/nvdimm/region_devs.c#n1030 > > > > struct_size() only applies to structures of the following kind: > > > > struct foo { > > int stuff; > > struct boo entry[]; > > }; > > > > and this scenario includes two different structures: > > > > struct nd_region { > > ... > > struct nd_mapping mapping[0]; > > }; > > > > struct nd_blk_region { > > ... > > struct nd_region nd_region; > > }; > > Yep - I neglected to actually look at the structures involved - you're > right, it doesn't apply here. > > > > > > [2]: > > > https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/tree/drivers/nvdimm/region_devs.c#n96 > > > > > > > In this scenario struct_size() does not apply directly because of the > > following > > logic before the call to devm_kzalloc(): > > Agreed, I missed that the calculation was more involved here. > > Thanks for the clarifications, you can add: > Reviewed-by: Vishal Verma Thanks, applied.