From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 445D732F765 for ; Mon, 17 Nov 2025 13:11:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763385101; cv=none; b=bImwRPOEs7WfMs7FPpDsI6HIFrWEW2MtuCoOgdwWV8qcIwqjrCELL4MQhhFJmK7rYwEz2lEXFgNGNWtAj4Wb3eGrmCECcyOohOdLyh7w0dwCL6kUHvJzQFPnE96Mcjjg579nOFMcvunjByUpo8/nr8syOgsA5k3dbMoBU9AZ5ik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763385101; c=relaxed/simple; bh=h38v3zpCAfMH+LpTc6wSw688KR9quyXTFOdnu5vd3ec=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BvcGbPwnLu7fliD9SsDG5HjsQq43NqsIr+1bqnDVcUSJrkUubErKWZvvjFMxxZdTTZZQKUEyAQr77D/GcVNmGWABMR3vMK9B0qMTK3V5jVgs3UpwiVpktBuLFn5qBOXgDssjVIAtVWnS81DaDZmjzR0O8AYXiOaWKi/FPhJAPcE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=yLVj8uYa; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yLVj8uYa" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-477a219db05so6384625e9.2 for ; Mon, 17 Nov 2025 05:11:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763385097; x=1763989897; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=01cC7ySHWhCFyMvXlU1Mt2SGt2tFSxfshKiVMAheuoI=; b=yLVj8uYaSCjrb72FiilVrWr/H2KRDyuSdftsRh+jw5/BjrJAimz9B8Z8ZRPkh94c+2 QFJqJKGGon/Bd/W6B7NNUPzBxKfwdPwLYn+HQxlUyJw+xmRJn7FMRqkeP1ozaUuC6x3I QuXmfmi8YFPxnH7jxyOcwQ94X20/89r3GonEhH6ReH+gt44g1AUgezz58AlQ2joi393A HQd2OYZDct2/mJnCXXZz/EWZH7f1dVSr2nla5VQuqxZYKK0TaneyStTqgk44kWYkQKnV DR1F0+ndJ/rXRpy6dn2rwgMZViDYMH5U46JNh+a4aTBW1xKkVrtO/6ShxNC/LOlWqnJs e6fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763385097; x=1763989897; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=01cC7ySHWhCFyMvXlU1Mt2SGt2tFSxfshKiVMAheuoI=; b=NQRRt3X1l0Ybs1n9cuCJVztKXgg10DbxAJfBiaa5YeyzCQxINIgjCCMQQkNWTumJzm Mh863Lm26ymOTP4LSlG9TTXAnNpZ+yDU6B6Fy5ivn1kMseBuAl54EQauvcudsShVuMTw 6RcnoZsnfCerTnRcbv9JOAl81i/4H5818aNO+kH0bb1ezs4dd7x6loGMcVLigD/FLFln AMlNmBdjIS1cyL6ZvJOXvVUZytqqDrVFyjHy2FUO8OTxIwfcouVHajAYlo4UbkeCRUHU eE3FPMFo7bGxRjh0CkB++vnM9FoQnV71waVj9X+rG0wnPK2vMmUBoxpvcuhKHwwrgyNF nAcA== X-Forwarded-Encrypted: i=1; AJvYcCW0lcxRkbPC+C2reP5f3JP0boMNgCe4CVyf2GsqmaeElz9vg+IWt1j8TSdyTUjwH1zbS9s4EbxahV946TM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2IH9a60ynY559w9z10+nFFUVY6z4of/pVXoJCbkaVgzooo8vW wZlQvZSkh9ZqJzsXjYPgLCcsgmF2hClBNTLAtSipGg6WM0eHhKTVY5d/GFLq95HrwiQ= X-Gm-Gg: ASbGncuk9qJj83OJM0fHRiZihurNFp3oyogUVQYTLL3xLMYB9rZlYKSeVEtg2FEVN9O CTo0RKMJQkgEhCkz33kRkdUWmDH92CfbiTfWErRksuJa7n/aMU/Con3/qVtOziwTJ4iZOqNKNnt webN+5uwGoJqwAtIPANf1Kofyfre34CWq6KW1Yat70vcrX4B7WNWl9VvdZaBhoTr/5KSGv5FjVN GCgSBMTNyD5CSd+pMt77gYqncTFdKD6FPboMh/AnBESTibp4MJe+19q8N5kNm+y+cUiu2SkrUhg Vf4tT4bR2/31A6WTF0hvU78IiqLDBRwDKhm6GKFK3lrg6xQTQxsXNaFoITLAcxYssQo/jGYoDhw HxuEQN+20+O2HQb/vd1v4Gq+Fg8/MXR0aDAb2eMKOtTm64fySGz0/vKZ3cDemvg15mWBj04mj8m hyH6fGZg== X-Google-Smtp-Source: AGHT+IHBC+9FsxtsdSHIREVrp/G6htztuNX/oUndRO09FTt+ZBKnna4hH64IsewtZZFfCyMd6Zo6+A== X-Received: by 2002:a05:600c:a43:b0:477:3543:3a3b with SMTP id 5b1f17b1804b1-4778fe59f2amr105544325e9.6.1763385097412; Mon, 17 Nov 2025 05:11:37 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4779973ddcfsm130108955e9.15.2025.11.17.05.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Nov 2025 05:11:36 -0800 (PST) Date: Mon, 17 Nov 2025 16:11:32 +0300 From: Dan Carpenter To: Alexander Lobakin Cc: Ally Heev , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Aleksandr Loktionov , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Subject: Re: [Intel-wired-lan] [PATCH v3] net: ethernet: fix uninitialized pointers with free attribute Message-ID: References: <20251106-aheev-uninitialized-free-attr-net-ethernet-v3-1-ef2220f4f476@gmail.com> <575bfdb1-8fc4-4147-8af7-33c40e619b66@intel.com> 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: <575bfdb1-8fc4-4147-8af7-33c40e619b66@intel.com> On Thu, Nov 06, 2025 at 03:07:26PM +0100, Alexander Lobakin wrote: > > diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c > > index 6d5c939dc8a515c252cd2b77d155b69fa264ee92..3590dacf3ee57879b3809d715e40bb290e40c4aa 100644 > > --- a/drivers/net/ethernet/intel/ice/ice_flow.c > > +++ b/drivers/net/ethernet/intel/ice/ice_flow.c > > @@ -1573,12 +1573,13 @@ ice_flow_set_parser_prof(struct ice_hw *hw, u16 dest_vsi, u16 fdir_vsi, > > struct ice_parser_profile *prof, enum ice_block blk) > > { > > u64 id = find_first_bit(prof->ptypes, ICE_FLOW_PTYPE_MAX); > > - struct ice_flow_prof_params *params __free(kfree); > > u8 fv_words = hw->blk[blk].es.fvw; > > int status; > > int i, idx; > > > > - params = kzalloc(sizeof(*params), GFP_KERNEL); > > + struct ice_flow_prof_params *params __free(kfree) = > > + kzalloc(sizeof(*params), GFP_KERNEL); > > Please don't do it that way. It's not C++ with RAII and > declare-where-you-use. > Just leave the variable declarations where they are, but initialize them > with `= NULL`. > > Variable declarations must be in one block and sorted from the longest > to the shortest. > These days, with __free the trend is to say yes this is RAII and we should declare it where you use it. I personally don't have a strong opinion on this either way, but other maintainers do and will NAK the `= NULL` approach. The documentation says you should do it that way and avoid the `= NULL` as well. The issue is with lock ordering. It's a FILO ordering, so if we require a specific unlock order then declaring variables at the top could mess things up. The counter argument is that if you declare a variable after a goto then that's undefined behavior as well. Clang will detect that bug so it be detected before it hits actual users. regards, dan carpenter