From mboxrd@z Thu Jan 1 00:00:00 1970 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 5585F20DDB; Fri, 22 Mar 2024 12:57:32 +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=1711112252; cv=none; b=eo3gtzWbc+3CGWl9hwH80+zNC7Eny8XskvDLHpXXuqPlmTwXiviZXvjeN5YcZk1hQgLJUoRoHVNfBqP6UjM2gFcdPiKaQzQAI2lJzYT6Y3dHVsKY5Y/8zYb/LFpWIU4x6qLzSSSpESNT6/398EMbFte7dfjRcjcYgykosCXEM4s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711112252; c=relaxed/simple; bh=vi6qepP3WZqihtomx/Ad9yWtRNe/QyPnUUouWN8vfoc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K+Xx9z95nP8yTKu7kPKX1rTzd8Qyh6dGfYZdDZL5p4ME5nvjV40BzPAxf2WoXMCR1r4xWOJU7ZdYV29OpfSciCcepSLWpRtF/7H+AWR/pucz4e2dzLtIX4DMQbApmnJnqbmpZcP/qLhKXQb+dvoStgJ6Y8C8aAq6ChXCAPJOEe4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mYOnqs3X; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mYOnqs3X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C3C3C433F1; Fri, 22 Mar 2024 12:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711112251; bh=vi6qepP3WZqihtomx/Ad9yWtRNe/QyPnUUouWN8vfoc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mYOnqs3XbPZ567x2XcqYUCB8z7YM6n71i0LA+G1lsomcgE09dZnAsQ5/jnVOTis/+ RPvyII8VqC0yle9uD7ZI419zJtCNjPgh2PUXSiKJa6Ta6yS7/N3S6qkotXWZpmYiaz ppB5rTjd2bgLZ0m95ihhxh1d4FPmSMv95QhZaPRoxFx9kfF/ZQNmP/sejCpxpxZTKH Ma1dDeNOZD/KjfsULlkpWSYR7ICpajzsaCRnPE6iAFhSyZzf5lcP9KnPGqq1J9QFaF lFRUdJHIeZy5ZsdhHsNZBIgz0JCqnnWZKZ2v1ra6cd3Grj9LXoI4gMoFBUQoNJv0Ak YtYq2gOuwo3Qg== Date: Fri, 22 Mar 2024 12:57:27 +0000 From: Simon Horman To: Dan Carpenter Cc: Maciej Fijalkowski , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Przemek Kitszel , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH v2 net] ice: Fix freeing uninitialized pointers Message-ID: <20240322125727.GE372561@kernel.org> References: <0efe132b-b343-4438-bb00-5a4b82722ed3@moroto.mountain> 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: <0efe132b-b343-4438-bb00-5a4b82722ed3@moroto.mountain> On Thu, Mar 21, 2024 at 05:42:12PM +0300, Dan Carpenter wrote: > 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. > > Fixes: 90f821d72e11 ("ice: avoid unnecessary devm_ usage") > Signed-off-by: Dan Carpenter > --- > v2: I missed a couple pointers in v1. > > The change to ice_update_link_info() isn't required because it's > assigned on the very next line... But I did that because it's harmless > and makes __free() stuff easier to verify. I felt like moving the > declarations into the code would be controversial and it also ends up > making the lines really long. > > goto goto err_unroll_sched; > > struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) = > kzalloc(sizeof(*pcaps), GFP_KERNEL); Thanks Dan, I agree with the approach you have taken here. And I apologise that it's quite likely that I skipped warnings regarding these problems when reviewing patches that introduced them - I did not understand the issue that this patch resolves. Reviewed-by: Simon Horman From mboxrd@z Thu Jan 1 00:00:00 1970 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 smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12658C54E71 for ; Fri, 22 Mar 2024 12:57:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 82142417C5; Fri, 22 Mar 2024 12:57:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uQ3gxhrGY5zO; Fri, 22 Mar 2024 12:57:35 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A0FF5417C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1711112255; bh=oOU41yqHsc2JOfg06tT7Wiq3jSb7rI6nDRxffU3WGr4=; h=Date:From:To:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=N3YHPimocT/SJhbebE0/iL/2hDjubHW14Xg903t9g0+Ae5uYgz1XDWV0XSZX9N6xK m8y0SYnlnVEB2io1n7er40c9oQJcbfpRJEGt/xkPrwz9g0WxodnCKmMZn13FTa9HD1 8vMbAoYJG+COujveWvdFvMBzyWOMNXnjeFkPYdT3zo9fV/cH9iI7bQx2/DGhYwrgrE y1542qgtAlWXYQeqoa4TeMMYKdxFznae2x9d17NKqWrTih/usJDA86HFvs0mJYRn5D qDTHgCkFoQ/5CJ5WaXX+2L1nzXiIk3rZT4pJal6gbr09iAkuGvGjkpVsgY21rhonje vtsQaxa6wruFQ== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id A0FF5417C0; Fri, 22 Mar 2024 12:57:35 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 42F5E1BF2EA for ; Fri, 22 Mar 2024 12:57:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 2C37A4043F for ; Fri, 22 Mar 2024 12:57:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XT4TX36Ts2fa for ; Fri, 22 Mar 2024 12:57:33 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=horms@kernel.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 7C6AF40439 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 7C6AF40439 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by smtp2.osuosl.org (Postfix) with ESMTPS id 7C6AF40439 for ; Fri, 22 Mar 2024 12:57:33 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 324116141D; Fri, 22 Mar 2024 12:57:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C3C3C433F1; Fri, 22 Mar 2024 12:57:29 +0000 (UTC) Date: Fri, 22 Mar 2024 12:57:27 +0000 From: Simon Horman To: Dan Carpenter Message-ID: <20240322125727.GE372561@kernel.org> References: <0efe132b-b343-4438-bb00-5a4b82722ed3@moroto.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0efe132b-b343-4438-bb00-5a4b82722ed3@moroto.mountain> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711112251; bh=vi6qepP3WZqihtomx/Ad9yWtRNe/QyPnUUouWN8vfoc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mYOnqs3XbPZ567x2XcqYUCB8z7YM6n71i0LA+G1lsomcgE09dZnAsQ5/jnVOTis/+ RPvyII8VqC0yle9uD7ZI419zJtCNjPgh2PUXSiKJa6Ta6yS7/N3S6qkotXWZpmYiaz ppB5rTjd2bgLZ0m95ihhxh1d4FPmSMv95QhZaPRoxFx9kfF/ZQNmP/sejCpxpxZTKH Ma1dDeNOZD/KjfsULlkpWSYR7ICpajzsaCRnPE6iAFhSyZzf5lcP9KnPGqq1J9QFaF lFRUdJHIeZy5ZsdhHsNZBIgz0JCqnnWZKZ2v1ra6cd3Grj9LXoI4gMoFBUQoNJv0Ak YtYq2gOuwo3Qg== X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=kernel.org X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=mYOnqs3X Subject: Re: [Intel-wired-lan] [PATCH v2 net] ice: Fix freeing uninitialized pointers X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maciej Fijalkowski , Przemek Kitszel , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , netdev@vger.kernel.org, Tony Nguyen , intel-wired-lan@lists.osuosl.org, Jakub Kicinski , Paolo Abeni , "David S. Miller" Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Thu, Mar 21, 2024 at 05:42:12PM +0300, Dan Carpenter wrote: > 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. > > Fixes: 90f821d72e11 ("ice: avoid unnecessary devm_ usage") > Signed-off-by: Dan Carpenter > --- > v2: I missed a couple pointers in v1. > > The change to ice_update_link_info() isn't required because it's > assigned on the very next line... But I did that because it's harmless > and makes __free() stuff easier to verify. I felt like moving the > declarations into the code would be controversial and it also ends up > making the lines really long. > > goto goto err_unroll_sched; > > struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) = > kzalloc(sizeof(*pcaps), GFP_KERNEL); Thanks Dan, I agree with the approach you have taken here. And I apologise that it's quite likely that I skipped warnings regarding these problems when reviewing patches that introduced them - I did not understand the issue that this patch resolves. Reviewed-by: Simon Horman