netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Simon Horman <horms@kernel.org>
Cc: Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	"Jiawen Wu" <jiawenwu@trustnetic.com>,
	Mengyuan Lou <mengyuanlou@net-swift.com>,
	"Dan Carpenter" <dan.carpenter@linaro.com>,
	<netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2] net: txgbe: Avoid passing uninitialised parameter to pci_wake_from_d3()
Date: Tue, 6 Jun 2023 18:57:21 +0200	[thread overview]
Message-ID: <ZH9lcWlEdVSd42yh@boxer> (raw)
In-Reply-To: <20230605-txgbe-wake-v2-1-82e1f0441c72@kernel.org>

On Tue, Jun 06, 2023 at 03:49:45PM +0200, Simon Horman wrote:
> txgbe_shutdown() relies on txgbe_dev_shutdown() to initialise
> wake by passing it by reference. However, txgbe_dev_shutdown()
> doesn't use this parameter at all.
> 
> wake is then passed uninitialised by txgbe_dev_shutdown()
> to pci_wake_from_d3().
> 
> Resolve this problem by:
> * Removing the unused parameter from txgbe_dev_shutdown()
> * Removing the uninitialised variable wake from txgbe_dev_shutdown()
> * Passing false to pci_wake_from_d3() - this assumes that
>   although uninitialised wake was in practice false (0).
> 
> I'm not sure that this counts as a bug, as I'm not sure that
> it manifests in any unwanted behaviour. But in any case, the issue
> was introduced by:
> 
>   3ce7547e5b71 ("net: txgbe: Add build support for txgbe")
> 
> Flagged by Smatch as:
> 
>   .../txgbe_main.c:486 txgbe_shutdown() error: uninitialized symbol 'wake'.
> 
> No functional change intended.
> Compile tested only.
> 
> Signed-off-by: Simon Horman <horms@kernel.org>
> Reviewed-by: Jiawen Wu <jiawenwu@trustnetic.com>

Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

> ---
> Changes in v2:
> - Correct referenced commit: it self referential in v1
> - Add added Reviewed-by tag from Jiawen Wu
> - Link to v1: https://lore.kernel.org/r/20230605-txgbe-wake-v1-1-ea6c441780f9@kernel.org
> ---
>  drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> index 0f0d9fa1cde1..cfe47f3d2503 100644
> --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
> @@ -457,7 +457,7 @@ static int txgbe_close(struct net_device *netdev)
>  	return 0;
>  }
>  
> -static void txgbe_dev_shutdown(struct pci_dev *pdev, bool *enable_wake)
> +static void txgbe_dev_shutdown(struct pci_dev *pdev)
>  {
>  	struct wx *wx = pci_get_drvdata(pdev);
>  	struct net_device *netdev;
> @@ -477,12 +477,10 @@ static void txgbe_dev_shutdown(struct pci_dev *pdev, bool *enable_wake)
>  
>  static void txgbe_shutdown(struct pci_dev *pdev)
>  {
> -	bool wake;
> -
> -	txgbe_dev_shutdown(pdev, &wake);
> +	txgbe_dev_shutdown(pdev);
>  
>  	if (system_state == SYSTEM_POWER_OFF) {
> -		pci_wake_from_d3(pdev, wake);
> +		pci_wake_from_d3(pdev, false);
>  		pci_set_power_state(pdev, PCI_D3hot);
>  	}
>  }
> 

  reply	other threads:[~2023-06-06 16:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06 13:49 [PATCH net-next v2] net: txgbe: Avoid passing uninitialised parameter to pci_wake_from_d3() Simon Horman
2023-06-06 16:57 ` Maciej Fijalkowski [this message]
2023-06-07 11:30 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZH9lcWlEdVSd42yh@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=dan.carpenter@linaro.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiawenwu@trustnetic.com \
    --cc=kuba@kernel.org \
    --cc=mengyuanlou@net-swift.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).