From patchwork Tue May 23 01:35:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13251350 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26021C7EE26 for ; Tue, 23 May 2023 01:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230359AbjEWBff (ORCPT ); Mon, 22 May 2023 21:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235097AbjEWBfJ (ORCPT ); Mon, 22 May 2023 21:35:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC75E9E; Mon, 22 May 2023 18:35:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2493162D90; Tue, 23 May 2023 01:35:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDDFFC433D2; Tue, 23 May 2023 01:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684805707; bh=ZVMZMDyY6PGeWLHzzzIJkAPjAJ4vdQOwm8Dt6MaAg4s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qKNIA0kdKj7tAvK2gRaXubxah2TuEOe4R60oz9LFjX5XtltGDbZh/dElX5UrODlWQ 96ti7dPfXUF5sBC6KfECWZLqEVHvqIOha3ZjDDE5qxy6zyLybP80e9Kh+PSOQr4Bbr 2s3vbccXWZ8VxznWOUzBsOznhssnAerPySzO5+a+ca9n29gvCR0vkoTaSOiLMACwE+ pgRpSmESYc559R8moYJ2qtlDgboB/EkoXI7qElZwEi9sDX8cyMcM/BwS2J8FU8QtdR XiJ7uYl+B9my4O5b0LCRRlCtKVGMBfZoCj7GNfNPW4TiLDsIJwTS69P8QgKWe1SLmL UoD4+02u+dQhA== Date: Mon, 22 May 2023 19:35:59 -0600 From: "Gustavo A. R. Silva" To: Eric Farman , Matthew Rosato , Halil Pasic , Vineeth Vijayan , Peter Oberparleiter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Cc: linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH 2/2][next] vfio/ccw: Use struct_size() helper Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Prefer struct_size() over open-coded versions. Link: https://github.com/KSPP/linux/issues/160 Signed-off-by: Gustavo A. R. Silva Reviewed-by: Eric Farman Reviewed-by: Kees Cook --- drivers/s390/cio/vfio_ccw_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c index 57906a9c6324..43601816ea4e 100644 --- a/drivers/s390/cio/vfio_ccw_drv.c +++ b/drivers/s390/cio/vfio_ccw_drv.c @@ -171,8 +171,7 @@ static int vfio_ccw_sch_probe(struct subchannel *sch) return -ENODEV; } - parent = kzalloc(sizeof(*parent) + sizeof(struct mdev_type *), - GFP_KERNEL); + parent = kzalloc(struct_size(parent, mdev_types, 1), GFP_KERNEL); if (!parent) return -ENOMEM;