From patchwork Fri Dec 15 23:24:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 10116731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E8BF860224 for ; Fri, 15 Dec 2017 23:24:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAD4D2A1B3 for ; Fri, 15 Dec 2017 23:24:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF4F02A1C6; Fri, 15 Dec 2017 23:24:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A63B2A1B3 for ; Fri, 15 Dec 2017 23:24:07 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A5D9722119BFA; Fri, 15 Dec 2017 15:19:24 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=dave.jiang@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9E21022119BCA for ; Fri, 15 Dec 2017 15:19:23 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Dec 2017 15:24:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,407,1508828400"; d="scan'208";a="12710737" Received: from djiang5-desk3.ch.intel.com ([143.182.136.93]) by orsmga003.jf.intel.com with ESMTP; 15 Dec 2017 15:24:05 -0800 Subject: [PATCH v3 1/4] ndctl: add support to alloc_intel_cmd for variable payload From: Dave Jiang To: dan.j.williams@intel.com Date: Fri, 15 Dec 2017 16:24:05 -0700 Message-ID: <151338024529.4485.13215296258978105688.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <151338007905.4485.4189717376304274611.stgit@djiang5-desk3.ch.intel.com> References: <151338007905.4485.4189717376304274611.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Certain payloads have variable size. The existing alloc_intel_cmd() does not take into account of that. Adding additional size for allocation. We do waste a little bit of the space because of the smart payload. Signed-off-by: Dave Jiang --- ndctl/lib/intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c index 3e4260f..b85a682 100644 --- a/ndctl/lib/intel.c +++ b/ndctl/lib/intel.c @@ -33,7 +33,7 @@ static struct ndctl_cmd *alloc_intel_cmd(struct ndctl_dimm *dimm, return NULL; } - size = sizeof(*cmd) + sizeof(struct nd_pkg_intel); + size = sizeof(*cmd) + sizeof(struct nd_pkg_intel) + in_size + out_size; cmd = calloc(1, size); if (!cmd) return NULL;