netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: UNGLinuxDriver@microchip.com, vladimir.oltean@nxp.com,
	claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com,
	davem@davemloft.net, kuba@kernel.org, andrew@lunn.ch,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] net: mscc: ocelot: Fix a resource leak in the error handling path of the probe function
Date: Mon, 14 Dec 2020 14:48:31 +0300	[thread overview]
Message-ID: <20201214114831.GE2809@kadam> (raw)
In-Reply-To: <20201213114838.126922-1-christophe.jaillet@wanadoo.fr>

On Sun, Dec 13, 2020 at 12:48:38PM +0100, Christophe JAILLET wrote:
> In case of error after calling 'ocelot_init()', it must be undone by a
> corresponding 'ocelot_deinit()' call, as already done in the remove
> function.
> 

This changes the behavior slightly in another way as well, but it's
probably a bug fix.

drivers/net/ethernet/mscc/ocelot_vsc7514.c
  1250          ports = of_get_child_by_name(np, "ethernet-ports");
  1251          if (!ports) {
  1252                  dev_err(ocelot->dev, "no ethernet-ports child node found\n");
  1253                  return -ENODEV;
  1254          }
  1255  
  1256          ocelot->num_phys_ports = of_get_child_count(ports);
  1257          ocelot->num_flooding_pgids = 1;
  1258  
  1259          ocelot->vcap = vsc7514_vcap_props;
  1260          ocelot->inj_prefix = OCELOT_TAG_PREFIX_NONE;
  1261          ocelot->xtr_prefix = OCELOT_TAG_PREFIX_NONE;
  1262          ocelot->npi = -1;
  1263  
  1264          err = ocelot_init(ocelot);
  1265          if (err)
  1266                  goto out_put_ports;
  1267  
  1268          err = mscc_ocelot_init_ports(pdev, ports);
  1269          if (err)
  1270                  goto out_put_ports;
  1271  
  1272          if (ocelot->ptp) {
  1273                  err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info);
  1274                  if (err) {
  1275                          dev_err(ocelot->dev,
  1276                                  "Timestamp initialization failed\n");
  1277                          ocelot->ptp = 0;
  1278                  }

In the original code, if ocelot_init_timestamp() failed we returned
a negative error code but now we return success.  This probably is what
the original authors intended, though.

  1279          }
  1280  
  1281          register_netdevice_notifier(&ocelot_netdevice_nb);
  1282          register_switchdev_notifier(&ocelot_switchdev_nb);
  1283          register_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb);
  1284  
  1285          dev_info(&pdev->dev, "Ocelot switch probed\n");
  1286  
  1287  out_put_ports:
  1288          of_node_put(ports);
  1289          return err;
  1290  }

regards,
dan carpenter


  reply	other threads:[~2020-12-14 11:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-13 11:48 [PATCH] net: mscc: ocelot: Fix a resource leak in the error handling path of the probe function Christophe JAILLET
2020-12-14 11:48 ` Dan Carpenter [this message]
2020-12-14 20:00   ` Christophe JAILLET
2020-12-14 22:54 ` Alexandre Belloni
2020-12-16 19:20 ` 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=20201214114831.GE2809@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vladimir.oltean@nxp.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).