lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BYAPR21MB1270500F9F47E805A19E2C00BF8A9@BYAPR21MB1270.namprd21.prod.outlook.com>
Date:   Mon, 1 Nov 2021 05:59:31 +0000
From:   Dexuan Cui <decui@...rosoft.com>
To:     Stephen Hemminger <stephen@...workplumber.org>
CC:     "davem@...emloft.net" <davem@...emloft.net>,
        "kuba@...nel.org" <kuba@...nel.org>,
        "gustavoars@...nel.org" <gustavoars@...nel.org>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        KY Srinivasan <kys@...rosoft.com>,
        "wei.liu@...nel.org" <wei.liu@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
        Shachar Raindel <shacharr@...rosoft.com>,
        Paul Rosswurm <paulros@...rosoft.com>,
        "olaf@...fle.de" <olaf@...fle.de>, vkuznets <vkuznets@...hat.com>
Subject: RE: [PATCH net-next 1/4] net: mana: Fix the netdev_err()'s vPort
 argument in mana_init_port()

> From: Stephen Hemminger <stephen@...workplumber.org>
> Sent: Saturday, October 30, 2021 1:07 PM
> 
> On Fri, 29 Oct 2021 17:54:05 -0700
> Dexuan Cui <decui@...rosoft.com> wrote:
> 
> > diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c
> b/drivers/net/ethernet/microsoft/mana/mana_en.c
> > index 1417d1e72b7b..4ff5a1fc506f 100644
> > --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> > +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> > @@ -1599,7 +1599,8 @@ static int mana_init_port(struct net_device *ndev)
> >  	err = mana_query_vport_cfg(apc, port_idx, &max_txq, &max_rxq,
> >  				   &num_indirect_entries);
> >  	if (err) {
> > -		netdev_err(ndev, "Failed to query info for vPort 0\n");
> > +		netdev_err(ndev, "Failed to query info for vPort %d\n",
> > +			   port_idx);
> 
> Shouldn't port_idx have been unsigned or u16?
> It is u16 in mana_port_context.

Thanks! I'll use "u32" and "%u" here.

I'll post v2 like the below. Please let me know if any further change is needed.

diff --git a/drivers/net/ethernet/microsoft/mana/mana.h b/drivers/net/ethernet/microsoft/mana/mana.h
index fc98a5ba5ed0..0a4246646447 100644
--- a/drivers/net/ethernet/microsoft/mana/mana.h
+++ b/drivers/net/ethernet/microsoft/mana/mana.h
@@ -359,6 +359,9 @@ struct mana_port_context {

        mana_handle_t port_handle;

+       /* This doesn't have to be u32, because the max_num_vports is u16:
+        * see mana_query_device_cfg().
+        */
        u16 port_idx;

        bool port_is_up;
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 1417d1e72b7b..b495e9a20324 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -479,6 +479,9 @@ static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver,
        return 0;
 }

+/* The range of the 'vport_index' parameter is actually only u16, but since
+ * the PF driver defines req.vport_index as u32, we also use u32 here.
+ */
 static int mana_query_vport_cfg(struct mana_port_context *apc, u32 vport_index,
                                u32 *max_sq, u32 *max_rq, u32 *num_indir_entry)
 {
@@ -1588,7 +1591,7 @@ static int mana_init_port(struct net_device *ndev)
 {
        struct mana_port_context *apc = netdev_priv(ndev);
        u32 max_txq, max_rxq, max_queues;
-       int port_idx = apc->port_idx;
+       u32 port_idx = apc->port_idx;
        u32 num_indirect_entries;
        int err;

@@ -1599,7 +1602,8 @@ static int mana_init_port(struct net_device *ndev)
        err = mana_query_vport_cfg(apc, port_idx, &max_txq, &max_rxq,
                                   &num_indirect_entries);
        if (err) {
-               netdev_err(ndev, "Failed to query info for vPort 0\n");
+               netdev_err(ndev, "Failed to query info for vPort %u\n",
+                          port_idx);
                goto reset_apc;
        }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ