Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1472486lqt; Wed, 20 Mar 2024 05:19:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXcvN1A94lCzx4d5s1rMVLNCVo/bSSq8lA8oAc8lX7HANSLmTfo2OxP9PdDFpJqwtpGo2QTFnIY3aJpibSXS0eu/ieNXDXDmsxiGm3OEg== X-Google-Smtp-Source: AGHT+IH4z+i9vz/r6ZFBuJ31qi6LH2PrmFAqBtmVoWd19gZfEAOUbSQnrJVS2/Sk179NV7yzE4Z4 X-Received: by 2002:a05:6870:d251:b0:222:3792:d968 with SMTP id h17-20020a056870d25100b002223792d968mr17518465oac.4.1710937172750; Wed, 20 Mar 2024 05:19:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710937172; cv=pass; d=google.com; s=arc-20160816; b=O1eR6gRu3V2VGkz4/rdw+lsfxmAFcWNC2RSmA2V8ZT6Kd3Ch1X8HWbpyg1zQVmaESY /F6TRX7ZMf0aUEoIUdDa6VwvkvawASvPt1/UPtD12gz5CUQGWNZ3UyrNFIFc8x+XoGiG 3+LchoNlfi0y4dAGpBqw0QrpqV52Y5zihZnd4NYZQhBn1m8tCsGNuO0E5OizDeqds+3F 5a28OO31Pn/CPChxUY0DCfm/G94Vi0K7J+VImBab+mZ7ikVCjSsgN8iI4LHnRQubGYrr XN7tb5q+tyh5iQohB5fgGFZYjKsrs86aC8Bf1E8FL8zbo00MjXH3Zo2NGF/Px9o3XtXD u/AA== 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=KhP5z213JRHgg+2Y4l04p0agR635gtrVnTmlg2I++II=; fh=qKwZIAGKn8gWm8wZbb8+bnQpPHwz52n4pZtMdfWOU04=; b=dSG1iy0w6ceXk89sy4dsb2vFwbK1ubp6Qy1cE5jKqVReE2669ZaltMdmGde38HT524 SmjVuOlHw3g+oCkwZGlni1rJJZqUa+pzfTT+2WSL79fHYebtoK9R3LOm0/Zs/xwqLk8g 7XIlwgHt4ZBHiftWcP+DzhKnYXHYZW7JgKEAw2M2HgnBYDhOHjYcjTrHNwh+C0j1PsLW 14f5kVTF10+61Ewdko28GBBmsnWz4UK1EpVxij0as8Xr7yNE5lJ1hBvU5BdC6HhX2DV1 3zgg7AwZHVsA4L3FPaJwUecFUE8pHw3aIf9u8wh+4QzDXRnx+5DivBo1h19azMK4JEJy lKJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=ey69IQD+; 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-108900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108900-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 t70-20020a638149000000b005dc883a6ba5si11831829pgd.500.2024.03.20.05.19.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 05:19:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108900-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=ey69IQD+; 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-108900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108900-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 D309B285CBA for ; Wed, 20 Mar 2024 12:19:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46BDD3FB97; Wed, 20 Mar 2024 12:19:23 +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="ey69IQD+" Received: from mout.web.de (mout.web.de [217.72.192.78]) (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 DD4173EA98; Wed, 20 Mar 2024 12:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.72.192.78 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710937162; cv=none; b=KMpiOBgLAMETMEr0XaVE0Jr1IRxGU6OilG062zoa0FCnNRAsyQtuQ5n96OrHIM6qidS6oElrFa4NI+AftueevzFchHfnXm9gq868pzVniClViQcbppzU1BglxnhIv9xWB4ZTKxc6Ckf6UYzr0h+bBRSkq4WpvRd5YgRld91KaKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710937162; c=relaxed/simple; bh=lRT9oSTfLR+JQlZUwPoWrQebKedyDM3ti0p4qPc/OEY=; h=Message-ID:Date:MIME-Version:To:Cc:References:Subject:From: In-Reply-To:Content-Type; b=nNaRyxB2XFrYgqu1Q3JuHjgXPen0CYJVdm/kYuLoW+x0oW0W4sQgBoue/CZje5BZ5lWuINHN6E4nhwh7HrBlYAc0x6gAG1IToqoL706IbPk+xz+7t2amzQAi6MTCzDSoJYSwcLmsGhiRxbR+VBk6OPXfa8tvY9Z3541VAhi2ImM= 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=ey69IQD+; arc=none smtp.client-ip=217.72.192.78 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=1710937128; x=1711541928; i=markus.elfring@web.de; bh=KhP5z213JRHgg+2Y4l04p0agR635gtrVnTmlg2I++II=; h=X-UI-Sender-Class:Date:To:Cc:References:Subject:From: In-Reply-To; b=ey69IQD+cdUgDYt2KtdYDS6PfEx1U3euVUDVZQd/I3lnASEWs2+7iDm8CTAAXG+c V907K5kHdsPrLxJ2DVHtBBzI1Wq8lwQ40+w2s7Qec3kJmhT9goNqPphA5lAY+HI6M CZW3YFtxbaK4PPFPgig47U7fz9lEm4tU5r4qTtmzWHfiE0CCyQHQvOdxyNckBl+ha IJOD63OrVpIKSAZiqod03i1daYuSVRGSnqLZZMDMgGJGqls8pNEqau/ijaBFAePYn ZHQnu5jyoobtE+z4aNDmxFc+l+nZK3/xh4HwE44TLdIdFKmbCLXvjb+rGSOTVGRMp JHUi//IsZIr0l0/AHw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.90.95]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1N9LIc-1qjpQC2DWG-015dwE; Wed, 20 Mar 2024 13:18:48 +0100 Message-ID: <4b8ee072-70bc-4a0a-8e43-e244f8ee2f22@web.de> Date: Wed, 20 Mar 2024 13:18:33 +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 , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jesse Brandeburg , Jiri Pirko , Paolo Abeni , Pucha Himasekhar Reddy References: <77145930-e3df-4e77-a22d-04851cf3a426@moroto.mountain> Subject: Re: [PATCH net] ice: Fix freeing uninitialized pointers Content-Language: en-GB From: Markus Elfring In-Reply-To: <77145930-e3df-4e77-a22d-04851cf3a426@moroto.mountain> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:PTUuB43Z3DS7y5k1LlzvJWE5GpgoYr2z888JWO4A8Mid5gKORZl MkpJK4sPj0ibCEfU/Pw4f5+CIFy2gNMghqQLHOhx/qdJ2joepGCvIS4FT/vzNi3ZISYJm5m W0rWME1EqkcsjFu2+pZtTZTKhWraCRg+epsZkoQ6DCHkmtw8Mxj9kbPwzJj8jb9ofEii8JW 9eLlGudzZsRxA81ao1Igw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:soozx22Hh6Q=;7yVwJkmtUEyeQXzSrPhICqaGpWL wbPjm8iTqr9BUqyukACz4OdGv9m9vWc3/fg29pK0KYzZZsDLtEvH0ZrLwJFZP48im70E3QMh8 D+g2/gtmggCoy70i5gd0tQMWyrix8wTEIPRATPDCqtwdr1aockW3cszBmSfN3+g9fgUJEr03n X2AZXgrXdislMFF9cKmCiuxQUib6tkR5jLqQ/jT3eEK/3FbAVSsz94RsiMGpfbPaczIM0E5AZ L3bwe2yFjjVrZkOg/oBVqXfrC3+J1T//XU18zo2T0b0AjqgZwRVbXVSQQj+Ms7IbmhuvlNw+/ fveFWGbZ1sMyvO9A5fma3wCii4WBsBBly70rIpn9021AXkNkNIXgw3YWRsS5ytNUtqJDacZdQ oxtzxCA0eWVlZYEpGByshiLpTEX9anZf20Q8icqiwfFUEeDU7a0jdKODkHo+n2wSPUyBko6LS 2AHZ+k48/WmQHiXsW5u2RTZuqJTcXJE5yln/0Lw4ujuU7nlN4faOW9g+mFNWp1kNyFNx5sCgY Yb8YfPFPED0KE8yRRm5xbEuB3U/ggpVTOvgB00yuUdmTGsbisqimEEnfbgurwAa0x+M3eSKNu 1GKcJZqia2LYnli/+5Yyysb7oy5LonCTHWVhOtcNKw2xuF9gdmdFcWDscJsN3ch8Nn8jRXB0b tz57Ae48zbuB0FHfO9Zg+ebV4uho2nVHhkKsF06LOfd462kDywP1pSssWQZupeUu51OSNV9PG KabbQuuIq0xxf0CNFfT+twKeG13Z+yZddKXnl8gNE2b3wFBvooJ2Xvqgyr8CBJbow1ahPmu4B 8WEuUavjN7uJsok8ZYho4JjUckMm8s/fThJNp3TJv9U6Y= > 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. I suggest to reconsider such information a bit more. =E2=80=A6 > +++ b/drivers/net/ethernet/intel/ice/ice_common.c > @@ -1002,8 +1002,8 @@ static void ice_get_itr_intrl_gran(struct ice_hw *= hw) > */ > int ice_init_hw(struct ice_hw *hw) > { > - struct ice_aqc_get_phy_caps_data *pcaps __free(kfree); > - void *mac_buf __free(kfree); > + struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) =3D NULL; > + void *mac_buf __free(kfree) =3D NULL; > u16 mac_buf_len; > int status; How do you think about to reduce the scope for affected local variables in= stead with the help of a small script (like the following) for the semantic patc= h language? @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) =3D kzalloc(sizeof(*pcaps), ...); @movement2@ attribute name __free; @@ -void *mac_buf __free(kfree); ... when any +void * mac_buf +__free(kfree) =3D kcalloc(2, sizeof(struct ice_aqc_manage_mac_read_resp), ...); Regards, Markus