From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com,
Yanfei Xu <yanfei.xu@windriver.com>, Andrew Lunn <andrew@lunn.ch>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 5.10 90/95] net: mdiobus: Fix memory leak in __mdiobus_register
Date: Mon, 25 Oct 2021 21:15:27 +0200 [thread overview]
Message-ID: <20211025191009.788587119@linuxfoundation.org> (raw)
In-Reply-To: <20211025190956.374447057@linuxfoundation.org>
From: Yanfei Xu <yanfei.xu@windriver.com>
commit ab609f25d19858513919369ff3d9a63c02cd9e2e upstream.
Once device_register() failed, we should call put_device() to
decrement reference count for cleanup. Or it will cause memory
leak.
BUG: memory leak
unreferenced object 0xffff888114032e00 (size 256):
comm "kworker/1:3", pid 2960, jiffies 4294943572 (age 15.920s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 08 2e 03 14 81 88 ff ff ................
08 2e 03 14 81 88 ff ff 90 76 65 82 ff ff ff ff .........ve.....
backtrace:
[<ffffffff8265cfab>] kmalloc include/linux/slab.h:591 [inline]
[<ffffffff8265cfab>] kzalloc include/linux/slab.h:721 [inline]
[<ffffffff8265cfab>] device_private_init drivers/base/core.c:3203 [inline]
[<ffffffff8265cfab>] device_add+0x89b/0xdf0 drivers/base/core.c:3253
[<ffffffff828dd643>] __mdiobus_register+0xc3/0x450 drivers/net/phy/mdio_bus.c:537
[<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
[<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
[<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
[<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
[<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
[<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
[<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
[<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
[<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
[<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
[<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
[<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
[<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969
[<ffffffff82660916>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:487
[<ffffffff8265cd0b>] device_add+0x5fb/0xdf0 drivers/base/core.c:3359
[<ffffffff82c343b9>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2170
[<ffffffff82c4473c>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
BUG: memory leak
unreferenced object 0xffff888116f06900 (size 32):
comm "kworker/0:2", pid 2670, jiffies 4294944448 (age 7.160s)
hex dump (first 32 bytes):
75 73 62 2d 30 30 31 3a 30 30 33 00 00 00 00 00 usb-001:003.....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff81484516>] kstrdup+0x36/0x70 mm/util.c:60
[<ffffffff814845a3>] kstrdup_const+0x53/0x80 mm/util.c:83
[<ffffffff82296ba2>] kvasprintf_const+0xc2/0x110 lib/kasprintf.c:48
[<ffffffff82358d4b>] kobject_set_name_vargs+0x3b/0xe0 lib/kobject.c:289
[<ffffffff826575f3>] dev_set_name+0x63/0x90 drivers/base/core.c:3147
[<ffffffff828dd63b>] __mdiobus_register+0xbb/0x450 drivers/net/phy/mdio_bus.c:535
[<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
[<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
[<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
[<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
[<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
[<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
[<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
[<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
[<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
[<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
[<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
[<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
[<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969
Reported-by: syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com
Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/phy/mdio_bus.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -544,6 +544,7 @@ int __mdiobus_register(struct mii_bus *b
err = device_register(&bus->dev);
if (err) {
pr_err("mii_bus %s failed to register\n", bus->id);
+ put_device(&bus->dev);
return -EINVAL;
}
next prev parent reply other threads:[~2021-10-25 19:39 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 19:13 [PATCH 5.10 00/95] 5.10.76-rc1 review Greg Kroah-Hartman
2021-10-25 19:13 ` [PATCH 5.10 01/95] parisc: math-emu: Fix fall-through warnings Greg Kroah-Hartman
2021-10-25 19:13 ` [PATCH 5.10 02/95] xhci: add quirk for host controllers that dont update endpoint DCS Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 03/95] io_uring: fix splice_fd_in checks backport typo Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 04/95] arm: dts: vexpress-v2p-ca9: Fix the SMB unit-address Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 05/95] ARM: dts: at91: sama5d2_som1_ek: disable ISC node by default Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 06/95] block: decode QUEUE_FLAG_HCTX_ACTIVE in debugfs output Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 07/95] xen/x86: prevent PVH type from getting clobbered Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 08/95] drm/amdgpu/display: fix dependencies for DRM_AMD_DC_SI Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 09/95] xtensa: xtfpga: use CONFIG_USE_OF instead of CONFIG_OF Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 10/95] xtensa: xtfpga: Try software restart before simulating CPU reset Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 11/95] NFSD: Keep existing listeners on portlist error Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 12/95] netfilter: xt_IDLETIMER: fix panic that occurs when timer_type has garbage value Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 13/95] dma-debug: fix sg checks in debug_dma_map_sg() Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 14/95] ASoC: wm8960: Fix clock configuration on slave mode Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 15/95] ice: fix getting UDP tunnel entry Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 16/95] netfilter: ip6t_rt: fix rt0_hdr parsing in rt_mt6 Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 17/95] netfilter: ipvs: make global sysctl readonly in non-init netns Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 18/95] lan78xx: select CRC32 Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 19/95] tcp: md5: Fix overlap between vrf and non-vrf keys Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 20/95] ipv6: When forwarding count rx stats on the orig netdev Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 21/95] net: dsa: lantiq_gswip: fix register definition Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 22/95] NIOS2: irqflags: rename a redefined register name Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 23/95] powerpc/smp: do not decrement idle task preempt count in CPU offline Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 24/95] net: hns3: reset DWRR of unused tc to zero Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 25/95] net: hns3: add limit ets dwrr bandwidth cannot be 0 Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 26/95] net: hns3: schedule the polling again when allocation fails Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 27/95] net: hns3: fix vf reset workqueue cannot exit Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 28/95] net: hns3: disable sriov before unload hclge layer Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 29/95] net: stmmac: Fix E2E delay mechanism Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 30/95] e1000e: Fix packet loss on Tiger Lake and later Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 31/95] ice: Add missing E810 device ids Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 32/95] drm/panel: ilitek-ili9881c: Fix sync for Feixin K101-IM2BYL02 panel Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 33/95] net: enetc: fix ethtool counter name for PM0_TERR Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 34/95] can: rcar_can: fix suspend/resume Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 35/95] can: peak_usb: pcan_usb_fd_decode_status(): fix back to ERROR_ACTIVE state notification Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 36/95] can: peak_pci: peak_pci_remove(): fix UAF Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 37/95] can: isotp: isotp_sendmsg(): fix return error on FC timeout on TX path Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 38/95] can: isotp: isotp_sendmsg(): add result check for wait_event_interruptible() Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 39/95] can: j1939: j1939_tp_rxtimer(): fix errant alert in j1939_tp_rxtimer Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 40/95] can: j1939: j1939_netdev_start(): fix UAF for rx_kref of j1939_priv Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 41/95] can: j1939: j1939_xtp_rx_dat_one(): cancel session if receive TP.DT with error length Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 42/95] can: j1939: j1939_xtp_rx_rts_session_new(): abort TP less than 9 bytes Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 43/95] ceph: skip existing superblocks that are blocklisted or shut down when mounting Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 44/95] ceph: fix handling of "meta" errors Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 45/95] ocfs2: fix data corruption after conversion from inline format Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 46/95] ocfs2: mount fails with buffer overflow in strlen Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 47/95] userfaultfd: fix a race between writeprotect and exit_mmap() Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 48/95] elfcore: correct reference to CONFIG_UML Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 49/95] vfs: check fd has read access in kernel_read_file_from_fd() Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 50/95] ALSA: usb-audio: Provide quirk for Sennheiser GSP670 Headset Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 51/95] ALSA: hda/realtek: Add quirk for Clevo PC50HS Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 52/95] ASoC: DAPM: Fix missing kctl change notifications Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 53/95] audit: fix possible null-pointer dereference in audit_filter_rules Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 54/95] net: dsa: mt7530: correct ds->num_ports Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 55/95] powerpc64/idle: Fix SP offsets when saving GPRs Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 56/95] KVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest() Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 57/95] KVM: PPC: Book3S HV: Make idle_kvm_start_guest() return 0 if it went to guest Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 58/95] powerpc/idle: Dont corrupt back chain when going idle Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 59/95] mm, slub: fix mismatch between reconstructed freelist depth and cnt Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 60/95] mm, slub: fix potential memoryleak in kmem_cache_open() Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 61/95] mm, slub: fix incorrect memcg slab count for bulk free Greg Kroah-Hartman
2021-10-25 19:14 ` [PATCH 5.10 62/95] KVM: nVMX: promptly process interrupts delivered while in guest mode Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 63/95] nfc: nci: fix the UAF of rf_conn_info object Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 64/95] isdn: cpai: check ctr->cnr to avoid array index out of bound Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 65/95] netfilter: Kconfig: use default y instead of m for bool config option Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 66/95] selftests: netfilter: remove stray bash debug line Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 67/95] net: bridge: mcast: use multicast_membership_interval for IGMPv3 Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 68/95] drm: mxsfb: Fix NULL pointer dereference crash on unload Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 69/95] net: hns3: fix the max tx size according to user manual Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 70/95] gcc-plugins/structleak: add makefile var for disabling structleak Greg Kroah-Hartman
2021-10-25 20:56 ` Pavel Machek
2021-10-25 21:07 ` Brendan Higgins
2021-10-25 21:40 ` Pavel Machek
2021-10-25 19:15 ` [PATCH 5.10 71/95] ALSA: hda: intel: Allow repeatedly probing on codec configuration errors Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 72/95] btrfs: deal with errors when checking if a dir entry exists during log replay Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 73/95] net: stmmac: add support for dwmac 3.40a Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 74/95] ARM: dts: spear3xx: Fix gmac node Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 75/95] isdn: mISDN: Fix sleeping function called from invalid context Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 76/95] platform/x86: intel_scu_ipc: Update timeout value in comment Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 77/95] ALSA: hda: avoid write to STATESTS if controller is in reset Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 78/95] libperf tests: Fix test_stat_cpu Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 79/95] perf/x86/msr: Add Sapphire Rapids CPU support Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 80/95] Input: snvs_pwrkey - add clk handling Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 81/95] scsi: iscsi: Fix set_param() handling Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 82/95] scsi: qla2xxx: Fix a memory leak in an error path of qla2x00_process_els() Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 83/95] sched/scs: Reset the shadow stack when idle_task_exit Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 84/95] net: hns3: fix for miscalculation of rx unused desc Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 85/95] scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma() Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 86/95] can: isotp: isotp_sendmsg(): fix TX buffer concurrent access in isotp_sendmsg() Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 87/95] s390/pci: fix zpci_zdev_put() on reserve Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 88/95] bpf, test, cgroup: Use sk_{alloc,free} for test cases Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 89/95] usbnet: sanity check for maxpacket Greg Kroah-Hartman
2021-10-25 19:15 ` Greg Kroah-Hartman [this message]
2021-10-25 19:15 ` [PATCH 5.10 91/95] tracing: Have all levels of checks prevent recursion Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 92/95] e1000e: Separate TGP board type from SPT Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 93/95] selftests: bpf: fix backported ASSERT_FALSE Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 94/95] ARM: 9122/1: select HAVE_FUTEX_CMPXCHG Greg Kroah-Hartman
2021-10-25 19:15 ` [PATCH 5.10 95/95] pinctrl: stm32: use valid pin identifier in stm32_pinctrl_resume() Greg Kroah-Hartman
2021-10-25 21:09 ` [PATCH 5.10 00/95] 5.10.76-rc1 review Florian Fainelli
2021-10-25 21:37 ` Pavel Machek
2021-10-26 0:59 ` Shuah Khan
2021-10-26 1:14 ` Fox Chen
2021-10-26 7:17 ` Naresh Kamboju
2021-10-26 9:16 ` Jon Hunter
2021-10-26 18:27 ` Sudip Mukherjee
2021-10-26 19:16 ` Guenter Roeck
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=20211025191009.788587119@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com \
--cc=yanfei.xu@windriver.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