stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	"Clément Léger" <clement.leger@bootlin.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 6.1 025/114] net: phylink: move phy_device_free() to correctly release phy device
Date: Mon, 13 Feb 2023 15:47:40 +0100	[thread overview]
Message-ID: <20230213144743.443479433@linuxfoundation.org> (raw)
In-Reply-To: <20230213144742.219399167@linuxfoundation.org>

From: Clément Léger <clement.leger@bootlin.com>

[ Upstream commit ce93fdb5f2ca5c9e2a9668411cc39091507f8dc9 ]

After calling fwnode_phy_find_device(), the phy device refcount is
incremented. Then, when the phy device is attached to a netdev with
phy_attach_direct(), the refcount is also incremented but only
decremented in the caller if phy_attach_direct() fails. Move
phy_device_free() before the "if" to always release it correctly.
Indeed, either phy_attach_direct() failed and we don't want to keep a
reference to the phydev or it succeeded and a reference has been taken
internally.

Fixes: 25396f680dd6 ("net: phylink: introduce phylink_fwnode_phy_connect()")
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/phy/phylink.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 2805b04d64028..a202ce6611fde 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1793,10 +1793,9 @@ int phylink_fwnode_phy_connect(struct phylink *pl,
 
 	ret = phy_attach_direct(pl->netdev, phy_dev, flags,
 				pl->link_interface);
-	if (ret) {
-		phy_device_free(phy_dev);
+	phy_device_free(phy_dev);
+	if (ret)
 		return ret;
-	}
 
 	ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface);
 	if (ret)
-- 
2.39.0




  parent reply	other threads:[~2023-02-13 14:53 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13 14:47 [PATCH 6.1 000/114] 6.1.12-rc1 review Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 001/114] hv_netvsc: Allocate memory in netvsc_dma_map() with GFP_ATOMIC Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 002/114] btrfs: limit device extents to the device size Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 003/114] btrfs: zlib: zero-initialize zlib workspace Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 004/114] ALSA: hda/realtek: Add Positivo N14KP6-TG Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 005/114] ALSA: emux: Avoid potential array out-of-bound in snd_emux_xg_control() Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 006/114] ALSA: hda/realtek: Fix the speaker output on Samsung Galaxy Book2 Pro 360 Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 007/114] ALSA: hda/realtek: Enable mute/micmute LEDs on HP Elitebook, 645 G9 Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 008/114] ALSA: hda/realtek: Add quirk for ASUS UM3402 using CS35L41 Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 009/114] ALSA: hda/realtek: fix mute/micmute LEDs dont work for a HP platform Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 010/114] Revert "PCI/ASPM: Save L1 PM Substates Capability for suspend/resume" Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 011/114] Revert "PCI/ASPM: Refactor L1 PM Substates Control Register programming" Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 012/114] tracing: Fix poll() and select() do not work on per_cpu trace_pipe and trace_pipe_raw Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 013/114] of/address: Return an error when no valid dma-ranges are found Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 014/114] can: j1939: do not wait 250 ms if the same addr was already claimed Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 015/114] HID: logitech: Disable hi-res scrolling on USB Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 016/114] xfrm: compat: change expression for switch in xfrm_xlate64 Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 017/114] IB/hfi1: Restore allocated resources on failed copyout Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 018/114] xfrm/compat: prevent potential spectre v1 gadget in xfrm_xlate32_attr() Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 019/114] IB/IPoIB: Fix legacy IPoIB due to wrong number of queues Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 020/114] xfrm: annotate data-race around use_time Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 021/114] RDMA/irdma: Fix potential NULL-ptr-dereference Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 022/114] RDMA/usnic: use iommu_map_atomic() under spin_lock() Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 023/114] xfrm: fix bug with DSCP copy to v6 from v4 tunnel Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 024/114] of: Make OF framebuffer device names unique Greg Kroah-Hartman
2023-02-13 14:47 ` Greg Kroah-Hartman [this message]
2023-02-13 14:47 ` [PATCH 6.1 026/114] bonding: fix error checking in bond_debug_reregister() Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 027/114] net: macb: Perform zynqmp dynamic configuration only for SGMII interface Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 028/114] net: phy: meson-gxl: use MMD access dummy stubs for GXL, internal PHY Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 029/114] ionic: clean interrupt before enabling queue to avoid credit race Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 030/114] ionic: refactor use of ionic_rx_fill() Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 031/114] ionic: missed doorbell workaround Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 032/114] cpufreq: qcom-hw: Fix cpufreq_driver->get() for non-LMH systems Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 033/114] uapi: add missing ip/ipv6 header dependencies for linux/stddef.h Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 034/114] net: microchip: sparx5: fix PTP init/deinit not checking all ports Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 035/114] HID: amd_sfh: if no sensors are enabled, clean up Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 036/114] drm/i915: Dont do the WM0->WM1 copy w/a if WM1 is already enabled Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 037/114] drm/virtio: exbuf->fence_fd unmodified on interrupted wait Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 038/114] cpuset: Call set_cpus_allowed_ptr() with appropriate mask for task Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 039/114] nvidiafb: detect the hardware support before removing console Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 040/114] ice: Do not use WQ_MEM_RECLAIM flag for workqueue Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 041/114] ice: Fix disabling Rx VLAN filtering with port VLAN enabled Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 042/114] ice: switch: fix potential memleak in ice_add_adv_recipe() Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 043/114] net: dsa: mt7530: dont change PVC_EG_TAG when CPU port becomes VLAN-aware Greg Kroah-Hartman
2023-02-13 14:47 ` [PATCH 6.1 044/114] net: mscc: ocelot: fix VCAP filters not matching on MAC with "protocol 802.1Q" Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 045/114] net/mlx5e: Update rx ring hw mtu upon each rx-fcs flag change Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 046/114] net/mlx5: Bridge, fix ageing of peer FDB entries Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 047/114] net/mlx5e: Fix crash unsetting rx-vlan-filter in switchdev mode Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 048/114] net/mlx5e: IPoIB, Show unknown speed instead of error Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 049/114] net/mlx5: Store page counters in a single array Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 050/114] net/mlx5: Expose SF firmware pages counter Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 051/114] net/mlx5: fw_tracer, Clear load bit when freeing string DBs buffers Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 052/114] net/mlx5: fw_tracer, Zero consumer index when reloading the tracer Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 053/114] net/mlx5: Serialize module cleanup with reload and remove Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 054/114] igc: Add ndo_tx_timeout support Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 055/114] net: ethernet: mtk_eth_soc: fix wrong parameters order in __xdp_rxq_info_reg() Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 056/114] txhash: fix sk->sk_txrehash default Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 057/114] selftests: Fix failing VXLAN VNI filtering test Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 058/114] rds: rds_rm_zerocopy_callback() use list_first_entry() Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 059/114] net: mscc: ocelot: fix all IPv6 getting trapped to CPU when PTP timestamping is used Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 060/114] selftests: forwarding: lib: quote the sysctl values Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 061/114] arm64: dts: rockchip: fix input enable pinconf on rk3399 Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 062/114] arm64: dts: rockchip: set sdmmc0 speed to sd-uhs-sdr50 on rock-3a Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 063/114] ALSA: pci: lx6464es: fix a debug loop Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 064/114] riscv: stacktrace: Fix missing the first frame Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 065/114] arm64: dts: mediatek: mt8195: Fix vdosys* compatible strings Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 066/114] ASoC: tas5805m: rework to avoid scheduling while atomic Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 067/114] ASoC: tas5805m: add missing page switch Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 068/114] ASoC: fsl_sai: fix getting version from VERID Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 069/114] ASoC: topology: Return -ENOMEM on memory allocation failure Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 070/114] clk: microchip: mpfs-ccc: Use devm_kasprintf() for allocating formatted strings Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 071/114] pinctrl: mediatek: Fix the drive register definition of some Pins Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 072/114] pinctrl: aspeed: Fix confusing types in return value Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 073/114] pinctrl: single: fix potential NULL dereference Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 074/114] spi: dw: Fix wrong FIFO level setting for long xfers Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 075/114] pinctrl: aspeed: Revert "Force to disable the functions signal" Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 076/114] pinctrl: intel: Restore the pins that used to be in Direct IRQ mode Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 077/114] cifs: Fix use-after-free in rdata->read_into_pages() Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 078/114] net: USB: Fix wrong-direction WARNING in plusb.c Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 079/114] mptcp: do not wait for bare sockets timeout Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 080/114] mptcp: be careful on subflow status propagation on errors Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 081/114] selftests: mptcp: allow more slack for slow test-case Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 082/114] selftests: mptcp: stop tests earlier Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 083/114] btrfs: simplify update of last_dir_index_offset when logging a directory Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 084/114] btrfs: free device in btrfs_close_devices for a single device filesystem Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 085/114] usb: core: add quirk for Alcor Link AK9563 smartcard reader Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 086/114] usb: typec: altmodes/displayport: Fix probe pin assign check Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 087/114] cxl/region: Fix null pointer dereference for resetting decoder Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 088/114] cxl/region: Fix passthrough-decoder detection Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 089/114] clk: ingenic: jz4760: Update M/N/OD calculation algorithm Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 090/114] pinctrl: qcom: sm8450-lpass-lpi: correct swr_rx_data group Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 091/114] drm/amd/pm: add SMU 13.0.7 missing GetPptLimit message mapping Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 092/114] ceph: flush cap releases when the session is flushed Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 093/114] nvdimm: Support sizeof(struct page) > MAX_STRUCT_PAGE_SIZE Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 094/114] riscv: Fixup race condition on PG_dcache_clean in flush_icache_pte Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 095/114] riscv: kprobe: Fixup misaligned load text Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 096/114] powerpc/64s/interrupt: Fix interrupt exit race with security mitigation switch Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 097/114] drm/amdgpu: Use the TGID for trace_amdgpu_vm_update_ptes Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 098/114] tracing: Fix TASK_COMM_LEN in trace event format file Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 099/114] rtmutex: Ensure that the top waiter is always woken up Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 100/114] arm64: dts: meson-gx: Make mmc host controller interrupts level-sensitive Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 101/114] arm64: dts: meson-g12-common: " Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 102/114] arm64: dts: meson-axg: " Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 103/114] Fix page corruption caused by racy check in __free_pages Greg Kroah-Hartman
2023-02-13 14:48 ` [PATCH 6.1 104/114] arm64: efi: Force the use of SetVirtualAddressMap() on eMAG and Altra Max machines Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 105/114] drm/amd/pm: bump SMU 13.0.0 driver_if header version Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 106/114] drm/amdgpu: Add unique_id support for GC 11.0.1/2 Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 107/114] drm/amd/pm: bump SMU 13.0.7 driver_if header version Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 108/114] drm/amdgpu/fence: Fix oops due to non-matching drm_sched init/fini Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 109/114] drm/amdgpu/smu: skip pptable init under sriov Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 110/114] drm/amd/display: properly handling AGP aperture in vm setup Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 111/114] drm/amd/display: fix cursor offset on rotation 180 Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 112/114] drm/i915: Move fd_install after last use of fence Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 113/114] drm/i915: Initialize the obj flags for shmem objects Greg Kroah-Hartman
2023-02-13 14:49 ` [PATCH 6.1 114/114] drm/i915: Fix VBT DSI DVO port handling Greg Kroah-Hartman
2023-02-13 20:57 ` [PATCH 6.1 000/114] 6.1.12-rc1 review Florian Fainelli
2023-02-13 21:18 ` Conor Dooley
2023-02-13 22:06 ` Allen Pais
2023-02-13 22:37 ` Justin Forbes
2023-02-13 23:29 ` Shuah Khan
2023-02-14  3:04 ` Bagas Sanjaya
2023-02-14  4:34 ` Ron Economos
2023-02-14  7:59 ` Naresh Kamboju
2023-02-14 10:52 ` Sudip Mukherjee

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=20230213144743.443479433@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=clement.leger@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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).