Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp26340imm; Tue, 28 Aug 2018 15:15:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbBcZRuJgq1MXYNzqja0Q1/5KU5l6jP6q9+ukB/jN0LwQ1MVTBdKXCFKwPAB85v0Jtpx4b6 X-Received: by 2002:a17:902:7587:: with SMTP id j7-v6mr3345646pll.256.1535494512985; Tue, 28 Aug 2018 15:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535494512; cv=none; d=google.com; s=arc-20160816; b=CiAq4ABG08vhYY8km66OtcxhsFtZzdMmFbqPmLrmwY+edG9lPhi6+oxk2apg286nzV B9NxjouzR6oJJzavtDuJ3/K4+B9kXVH04fYgWCWP6S6g2+VJeQnXlGVJgVdK27XQLzsF k1vDZ9V2U/3Pg7En7EYaiRAy/sXGXYOSE/HbrMV601bIw2T42pueXaQOavtAGOdAZCPn pQ7nfP+hjo2Dpyo35MB7zVE2oE28inNsQbA7vcMaVajlVqKSUJSYKg3oWcRhIRc/J4sh qn7lGg1EYLbcdi5ldjKW89kmPq3vKlvs1nKPDnPKOPjpnyUuqkojsGyEzsTLy4t7Sprs 4n7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=9dFGjebJjz27mVnX1K8ntPH3IBTI5lJohhWILD2h0XA=; b=ehq3Sl34T72ry5SJMUziAsUO/5eB/UK+YPBuAownH5eaV3+27HPZkL4xbtOV5BBftR oGCIToo7+Vsj8nAD9C6AIkBujKqel76D/edOShtuGrBFhjto6rrLnQXNzEeM7XrpMDvT 0l9qVshu3xEJYHAdsyFkWpkcD8oKX0B8xyEG05qMjAEgMvYlZcGILUvpV1M07KB8uFPE dXNj15Vmc2nzF1Inym+V2U5CercOUSSZ94wblu28aQu+sGp4KdMCgPsan6wtXcrm4CSE g5lbVhZ9B/iRlHFJEK9SMo+4uCJR7C6pWpIrBlpR2d8WHUG20v1pRWxjU2Q6bA46hn2y agfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sHsaa3kc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22-v6si1984295pfb.185.2018.08.28.15.14.57; Tue, 28 Aug 2018 15:15:12 -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=@kernel.org header.s=default header.b=sHsaa3kc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727605AbeH2CHK (ORCPT + 99 others); Tue, 28 Aug 2018 22:07:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:59540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727484AbeH2CHJ (ORCPT ); Tue, 28 Aug 2018 22:07:09 -0400 Received: from localhost (unknown [104.132.0.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 849AD2083B; Tue, 28 Aug 2018 22:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1535494408; bh=a/BSTxajlUOVRse+IpRQwwZyRaBWi8907g0RiNv0Yo0=; h=To:From:In-Reply-To:Cc:References:Subject:Date:From; b=sHsaa3kchp47VukBewo57ihQqyLi1Hl61vklV4UiKGs1hAHParA2LjVc5Dk6psLoC 2V2NnSv3sjB18E8OD3es9df7Sc+TX/B53eZvxM/ytRpcv+Es+rgH8yxlWPCeVRyNpC XcRpFMcflf2zKmwlsRyHQ0wnoVuE1vmQnTPDctP4= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: "Gustavo A. R. Silva" , Avi Fishman , Brendan Higgins , Michael Turquette , Nancy Yuen , Patrick Venture , Tomer Maimon From: Stephen Boyd In-Reply-To: <20180823230654.GA11576@embeddedor.com> Cc: openbmc@lists.ozlabs.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , "Gustavo A. R. Silva" References: <20180823230654.GA11576@embeddedor.com> Message-ID: <153549440786.129321.7169734992268309360@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH] clk: npcm7xx: fix memory allocation Date: Tue, 28 Aug 2018 15:13:27 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Gustavo A. R. Silva (2018-08-23 16:06:54) > 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: > = > struct foo { > int stuff; > void *entry[]; > }; > = > instance =3D kzalloc(sizeof(struct foo) + sizeof(void *) * count, > GFP_KERNEL); > = > Instead of leaving these open-coded and prone to type mistakes, we can > now use the new struct_size() helper: > = > instance =3D kzalloc(struct_size(instance, entry, count), GFP_KERNEL); > = > Notice that, currently, there is a bug during the allocation: > = > sizeof(npcm7xx_clk_data) should be sizeof(*npcm7xx_clk_data) > = > Fix this bug by using struct_size() in kzalloc() > = > This issue was detected with the help of Coccinelle. > = > Cc: stable@vger.kernel.org > Signed-off-by: Gustavo A. R. Silva > --- Applied to clk-fixes