Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2372960rdb; Mon, 12 Feb 2024 02:41:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUoHUDFevpA72AAKIWKGMt5YQ3bAC7yNmRyt2GaRhvL2hUOTWs4qDcFpCrC+3Un+6d+T96QEM0Yj++TAwdGvCWK4bnVHvu7PlN2DBD61w== X-Google-Smtp-Source: AGHT+IEfTl6GWTlflV5IJ2poYz6QNzfNY75sKP8TCNJWOugUcDenzIFFMGhub5zyfzLALODGwxmD X-Received: by 2002:aca:1c15:0:b0:3c0:3765:96df with SMTP id c21-20020aca1c15000000b003c0376596dfmr2298621oic.21.1707734489952; Mon, 12 Feb 2024 02:41:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707734489; cv=pass; d=google.com; s=arc-20160816; b=hKJd2IgS1XcCvWAOtTfSKY/YVhpUxOTMKdQGYOCSBjbzdm0KED4wf/fhnllFPzYa6d h2ogfOzLg+3ornhlnr3xW96RqqJdRVzMYHACzxATIYAhp+0pDDkOguIIwfOhLKfBOTDS y4KwOSs+NYcbY2MyVqpbj1U8ePc4smNpFqSSmxwApJSP2eS1rJxVTqKh8DCwDD4DfF4S iQ1tU+XePO0KQVS4goBebj54AbsXSBzRCOhqwcBsbghHsLicfs4w75j31GsvrqgzSSrp ztqKP3SfVHF2IeApxPlpBv6isXxwDnD5xDVgbMXWwJiPwPKS8+DdxyeGte5euAq3lANP rH5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ULcAVFleHA/pbULQ10YCgbF3jlv9u8WVQN2wPP0jd8Q=; fh=dThhN71pkwCQQcyIYecOyTE7apNaurW+F7VJKUVwfu4=; b=nw73wHNJoMGNzsL52VDmz31MhGXrr8ETwSvaZmJYHbjBGmabfl3354u8LUlNpTvtEf GKrEOBzqZ994VbN5wC4U4EJC07oFrssVTo+pjm/iSDWX0v6z+3oakQnSTZ3dCozPK8Y3 dxxBts1rCc2F75XEix7JqLZHsTMdqEaLfUIKH4FH6sQsDX6Alr+LYgNUQID76tqzFkw2 NJ7Xh9QRrD8wVVOqQhSh4lybGtufqJKHB3wLpYgxYcHtuGg8iGBYK9jQ2hRF4ry1ZDN0 iXnM/yrDQ4Su+BR4Nnyb/eEVbYtWr6N2tnqHdns5PJgYsgsxJ+WKwgHpUz25dsv07Vxp Ei7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T8nE9Ohy; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-61337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61337-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org X-Forwarded-Encrypted: i=2; AJvYcCUHQDrF6GyvJb94P3oKgJ9ncwYExc7URnPewDXRaP+x8qEaCMCxP2ytuk9FCZQg80v/cYjm9RC4OpZimGLYFzOhW1ioY5hFRGrwe08cYw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r20-20020ac87954000000b0042c4cce6f63si82855qtt.117.2024.02.12.02.41.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 02:41:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T8nE9Ohy; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-61337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61337-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 676A61C222C6 for ; Mon, 12 Feb 2024 10:41:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CEDD24B2F; Mon, 12 Feb 2024 10:41:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="T8nE9Ohy" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4595920DCF for ; Mon, 12 Feb 2024 10:41:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707734482; cv=none; b=coprjqJR/QjuM1F6Ddd3xJgHXGaF0bfsQKfWD031Mm9qxkkcxSu8x4PYg1MjdQF8G8uuFhvJykbbVNr46emguvgnnaV66vGmIOmdvvq/vG328iBwqU6p/5PqeFq10F7dpzxnWP6ugNIhGdlf9zLhSCuxP65rGpuaIee2iYQ5w8Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707734482; c=relaxed/simple; bh=COzgZIdVTzpQkoTJd5fKW1JsU3KKcKHwzae3qudrIzM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OU7LuRUYQAp6RoGLJQ+23WT60VpXmjCLklD2vYtYT3iu0nLCKzQjZ/TpvuNwV4RGRtBRvAtHIhQSL4G03kk6rJ1u6awPSYXA9jGOPqfJLo3w1ZS/fP36/0htosKbHCIxtnWBJswI4XLS6aeyrMCFkjJBHlxBGxJZjeqo+19Pcgs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=T8nE9Ohy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FDB3C433F1; Mon, 12 Feb 2024 10:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1707734481; bh=COzgZIdVTzpQkoTJd5fKW1JsU3KKcKHwzae3qudrIzM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T8nE9Ohy3nIgqrI76nu5E6WcpXBNmTg6GmHrWS8z1cghzATgA4VqwREOk0ZYjuwXA Nihd9RFhKol0ggK81o8kALD4CTGlZ034EE6wzQUt80iHJKszo1lqT5906QtBYKSNFZ qv9ib6fKn+Yg6dwTk4IeiWA0kmmxtr7nj35aKUFA= Date: Mon, 12 Feb 2024 11:41:18 +0100 From: Greg Kroah-Hartman To: Arnd Bergmann Cc: Sakari Ailus , linux-kernel@vger.kernel.org, Hans de Goede , Tomas Winkler , Wentong Wu Subject: Re: [PATCH 3/3] mei: vsc: Assign pinfo fields in variable declaration Message-ID: <2024021240-encode-disjoin-c8c2@gregkh> References: <20240212094618.344921-1-sakari.ailus@linux.intel.com> <20240212094618.344921-4-sakari.ailus@linux.intel.com> <2024021210-freeway-unblessed-d966@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Feb 12, 2024 at 11:14:29AM +0100, Arnd Bergmann wrote: > On Mon, Feb 12, 2024, at 11:02, Greg Kroah-Hartman wrote: > > On Mon, Feb 12, 2024 at 11:46:18AM +0200, Sakari Ailus wrote: > >> Assign all possible fields of pinfo in variable declaration, instead of > >> just zeroing it there. > >> > >> Signed-off-by: Sakari Ailus > >> --- > >> drivers/misc/mei/vsc-tp.c | 16 ++++++++-------- > >> 1 file changed, 8 insertions(+), 8 deletions(-) > >> > >> diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c > >> index 200af14490d7..1eda2860f63b 100644 > >> --- a/drivers/misc/mei/vsc-tp.c > >> +++ b/drivers/misc/mei/vsc-tp.c > >> @@ -447,11 +447,16 @@ static int vsc_tp_match_any(struct acpi_device *adev, void *data) > >> > >> static int vsc_tp_probe(struct spi_device *spi) > >> { > >> - struct platform_device_info pinfo = { 0 }; > >> + struct vsc_tp *tp; > >> + struct platform_device_info pinfo = { > >> + .name = "intel_vsc", > >> + .data = &tp, > >> + .size_data = sizeof(tp), > >> + .id = PLATFORM_DEVID_NONE, > >> + }; > > > > But now you have potential stack data in the structure for the fields > > that you aren't assigning here, right? Is that acceptable, or will it > > leak somewhere? > > > > This is why we generally do not do this type of style. So unless you > > are fixing an issue here, please don't do it. > > If you have any initializer, all named fields in the structure > are zeroed. The only bits of the structure that may contain > stack data are for padding between fields, but that doesn't > actually change here from the previous version. I thought we had looked into that before and it would 0 out everything if you just had the {0} initializer, including holes? Or was it not, or did it depend on the compiler/version? Sorry, I never remember and so just recommend a memset which should be the same overall. > The old version you have here just skips the named fields > and otherwise would end up lookingn like > > struct platform_device_info pinfo = { > .parent = 0, > }; > > which is still a partial initializer and has the added > problem of relying on a literal '0' as a NULL pointer. > In modern compilers, one can write this as > struct platform_device_info pinfo = {}, but Sakari's > version looks best to me. Ok, as long as there's no stale stack data, I'm ok with it. thanks, greg k-h