Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp712413lqp; Thu, 21 Mar 2024 13:11:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3zpUQGl70cX3XW8cfbfNW3GEvc4jG/1Yf3s0FygOlhTdk2IALVB6m49X4oJ91vaFBUJX7cBp/d7VSCSJ1aDw6yGLP/nwe/8WZ4D2Czw== X-Google-Smtp-Source: AGHT+IHYX4HLNWxW7ylhqGwkIrkVsJKdnQjiVC+BfPJailNuThwLeRTMZ/Yh5TM1k1lDrRKZ7THi X-Received: by 2002:a05:6358:7627:b0:17e:68ac:6435 with SMTP id r39-20020a056358762700b0017e68ac6435mr476040rwg.8.1711051915055; Thu, 21 Mar 2024 13:11:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711051915; cv=pass; d=google.com; s=arc-20160816; b=sE1jyEbuW+WM67Owk28QP3LnTTRpJnofAU7eGT1e4KmDuCZIumIvKMBZVS5kj5Tp6P nUOJvNteMsL5sqwjSYhGJUfcs0k7A1SrJDcUfQXhPQH3lLrOzGyWCqKvU2ovCBP7ka+8 jf1jyyyKQWTqz5QmYEKlOhIFEEJiK9X1hgtNcy5JVmO3wgl3BCePjxlYb6PTeepEtAXB s6/kCUx2xTLx5QFN2MU0nyjf4g9SGq4wfO0LHy85arLezPRz2T7vPwr4SEhqqV/XMHlF xsOM6tpy3ovtEbIlTlqaELbGUymm9YHDCzx8NHcPjNsefQiUnMqho4TWwj7D4ypOzG7N k6mw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:in-reply-to:from :content-language:subject:references:cc:to:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=HP94er+kV3GasVjf02u3F9ZYkvcXZGx9D3xC+m1al/k=; fh=ccNyF2xafPOrq7Zb2rL9iXiM3qRfZk/TpeA+ZDlD6FA=; b=ArVZoHy8YXYEx7Xbd3kz+/xTs3pGUp80qwBU7u4d0ItcTT4EpPri5f+P8vsiydWTmr yjeU+cv4+zqi+tUziQocECqNvp4XalauSykDDnJJvJY0mxfw9Vqvn9INpMoaXaGdKk77 sK5o6S7gmJIA94TFQOsQGo4/HqBnDBwthlY3RJATzTxr/hsdRxKaCF76G/OPBVKsF/AW 4Bj7tbzgG7jMj4xBwVBr+ItMVlZ2CFWTEyyopkidoILMfNPKB0hr4s8ShpuBxY//1Wl5 yH0EpvGG+EoEl5tHCV0gp07i/CxcVggo7hTU5/UGBSn4CRAEfMEPdDH02cgayE2S2Zth 9ldA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=Ohj113M2; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-110630-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p19-20020a639513000000b005e85aa10588si416599pgd.455.2024.03.21.13.11.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 13:11:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110630-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=Ohj113M2; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-110630-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AE0322848EB for ; Thu, 21 Mar 2024 20:11:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1AF5134CCB; Thu, 21 Mar 2024 20:11:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="Ohj113M2" Received: from mout.web.de (mout.web.de [212.227.15.14]) (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 712A156B98; Thu, 21 Mar 2024 20:11:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711051905; cv=none; b=OMeC+fpjwAN0DtJvflQnKjYQkXZvQ3RDU526dBw4g9SekL+ksvjD2UwRKMmg3bfGYLBQ1ooMpfYp21u53TfO2blYd4v63cteyhsrgONBL5cHvGpyFyZ2qc4yThjH8qp8IvS5gmvzauKucd/rY7crjEFbevjrTbaJSutHpeA8ZD8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711051905; c=relaxed/simple; bh=/2XDIlMNYS8/iY2ARJ5Fld7/GNYjUZk7UV6XTc7Kqsk=; h=Message-ID:Date:MIME-Version:To:Cc:References:Subject:From: In-Reply-To:Content-Type; b=eq8tuzO7t1c+wAwKD99wDP6dImS7hpEux7D+5MMcdxxUPEa2hTNCf6B6KFOn7Qg/Pi2r63H+AnNKAdyv/W8uXdq4i4n5ucxFJGFrZFyxx6tGVA8nmgHGVFDi7R8p3r4G6UdHdR4JZD3QDlJobTvIOhum/dYrtkbepxS4EiscCwc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=Ohj113M2; arc=none smtp.client-ip=212.227.15.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1711051895; x=1711656695; i=markus.elfring@web.de; bh=HP94er+kV3GasVjf02u3F9ZYkvcXZGx9D3xC+m1al/k=; h=X-UI-Sender-Class:Date:To:Cc:References:Subject:From: In-Reply-To; b=Ohj113M2xWNnZpo7zw6o3IRAbBcp6R/t4iips3r3U920IM3MjiGXBn15VjlXyh2b iszYGr5qT9m6SsC5r3viqzQ9GkIs8+AXPkRcTvMgiH75mFEhvOEDNx0ezD/Vb0Fdv hP3Qm3UHC+pZCytnyRUinD7w+2QmtfOhHzykHXmw1X/8N17Pnsgd3V9J27LDUjWiL K7GmKt2QTfjYy3uQJlDFW9AyGDsa3WUt2izVju3+IIdqmBEuwN+PHfVKl/UkUEOLW TsDlKXLFuIgcSXUqRZv0v9Ps+OQctuJnMr5MSwlYBUNzXWuN3q45rrlW5ZIkXDFfL L+RW7rMXRujdp9jmXg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.90.95]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M8C07-1rjnlJ0KNn-00CkW1; Thu, 21 Mar 2024 21:05:38 +0100 Message-ID: <0d7062e1-995b-42bc-8a62-d57c8cb588ee@web.de> Date: Thu, 21 Mar 2024 21:05:35 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Dan Carpenter , kernel-janitors@vger.kernel.org, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Maciej Fijalkowski , Przemek Kitszel , Tony Nguyen Cc: LKML , Alexander Lobakin , Andy Shevchenko , David Laight , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesse Brandeburg , Jiri Pirko , Jonathan Cameron , Julia Lawall , Kees Cook , Lukasz Czapnik , Paolo Abeni , Pucha Himasekhar Reddy References: <0efe132b-b343-4438-bb00-5a4b82722ed3@moroto.mountain> Subject: Re: [PATCH v2 net] ice: Fix freeing uninitialized pointers Content-Language: en-GB From: Markus Elfring In-Reply-To: <0efe132b-b343-4438-bb00-5a4b82722ed3@moroto.mountain> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:f30MnlCTiWPDt1zm7PlXXn3w8Vl/ZOlATngou/8kstVjQ3Vtjmc NwEr7iAZYqjF/kCilniZdpv/ZLPs3A65OoLDtTMhNEIpAf2F3c8X9j/zin2Z/6rxkVK/bL3 Wd7ZA7beckUcLMwzclkVVdoZI80PLUcb7qXLoHdtCIh0JsPV3Ctj3JBF/3V2PoYrWqycho0 7onxYACnS19+yZ9c1V4Ag== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:X2SR5Bg9eus=;EsgC33vWFTVn58hHEBNEPF38Rrl CULKBP/GMFGAZzCkl/I+QKpv2zx/UmKeEXzWhzA8tkpmH4pA05yI58gXd8aPMlQRo+vXZ0g9e 3vdZ9gUpf1OvJ5ENRAHCnG+NQZabvdjqV/6JwkdcO06hQYZqEUL6w1svA2UmD8fTX3L7eDuSy GthD2D2GbGCQN3t4gIypBIGb1bD0ATnGsIL1qSaVEr34JZtp2H8QZYootESVtgminvoM5ZIHz CrETzHiOnDA9HSVpijq0dh7Gk29iyNk4CjyKBx2nnC9Oa6+HuhEiE8VKNKOkQLKscw5S+rz0r n+IRXcV95zmeKDKKr7ICaj6oRIXfJ+SuIf6YBEZhjK16xQ3bhXUKRpvl6WFKxw1ibBrrg4r7N JOdj2N9961SHi9BJsH0gKdka+QsUM93IbN1Mjy1d/mv4lKZmx83TDciQVgF71Dq6lFkwWPye6 YHPXzvmcQmPRvgCyNmGBhyKcMlw9E4Pf9b1ABrq8Trf2psGZHrDUtWCN5pcMP+NoSkVJwqTGm kRAYADbhG6fDuduIZWi3kYTWSMmF2E+HnN6xHjox+VRGFx+0Mrg8APJrVR55AnRpmaIwK6fPF /I891Y3iTsB+qN2zup5tfSw072LFbBWBYq/BNwxDYuSOH17vkWLoEhpG6bKy5vvoXGMNl9qY+ IDt5KkknnGPMuSGwxczBT4PZeQIYsQHf7tuaPt24XxSofTBQNJ87zdG4pp2OUNzAC2xDjAoqf Cx/ojIX9EGvYib8qjgKvy8asvEyUZ9e9uzCh7kkNekla2o60ns7KRvW17qUhZZl9DFw0jvI0Q oUSTbhHJflD2aEv7pc2aOHIYjEEoYQLDzH960/3o/GttE= > Automatically cleaned up pointers need to be initialized before exiting > their scope. In this case, they need to be initialized to NULL before > any return statement. Will any adjustments become relevant also for this change description if scope reductions would become more appealing for affected local variables? How much can a small script (like the following) for the semantic patch language (Coccinelle software) help to achieve a better common understanding for possible source code transformations? // See also: // drivers/net/ethernet/intel/ice/ice_common.c @movement1@ attribute name __free; @@ -struct ice_aqc_get_phy_caps_data *pcaps __free(kfree); ... when any +struct ice_aqc_get_phy_caps_data * pcaps +__free(kfree) = kzalloc(sizeof(*pcaps), ...); @movement2@ attribute name __free; @@ -void *mac_buf __free(kfree); ... when any +void * mac_buf +__free(kfree) = kcalloc(2, sizeof(struct ice_aqc_manage_mac_read_resp), ...); // See also: // drivers/net/ethernet/intel/ice/ice_ethtool.c @movement3@ attribute name __free; @@ -u8 *tx_frame __free(kfree); int i; ... when any if (ice_fltr_add_mac(test_vsi, ...)) { ... } + +{ +u8 *tx_frame __free(kfree) = NULL; if (ice_lbtest_create_frame(pf, &tx_frame, ...)) { ... } ... when any +} + valid_frames = ice_lbtest_receive_frames(...); Regards, Markus