diff options
| author | Mieczyslaw Nalewaj | 2026-06-27 15:13:09 +0000 |
|---|---|---|
| committer | Jonas Jelonek | 2026-06-28 20:26:47 +0000 |
| commit | 11a237101e217a00acb4d948facb18686862a487 (patch) | |
| tree | e56761cb76d0279823d091755d5ae3ec4ba2b4b7 | |
| parent | 6dead2869209f4ff9825f3169c129c5ef04f6273 (diff) | |
| download | openwrt-11a237101e217a00acb4d948facb18686862a487.tar.gz | |
rtl8367b: fix RTL8367S-VB vlan mc memory handling
The RTL8367S-VB (Family D) uses a software-emulated VLAN MC table
(emu_vlanmc) since it lacks hardware support for the VLAN MC registers
used by earlier chips.
- Add missing NULL check after kzalloc() in rtl8367b_init_regs() to
prevent NULL pointer dereference on allocation failure.
- Add missing kfree(smi->emu_vlanmc) in rtl8367b_remove() to prevent
memory leak on driver unload.
Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/23970
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
(cherry-picked from beb880855c3f5011b2a9cf5428061d7ce62a74ff)
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
| -rw-r--r-- | target/linux/generic/files/drivers/net/phy/rtl8367b.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367b.c b/target/linux/generic/files/drivers/net/phy/rtl8367b.c index ae309367dc..01dc20f431 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367b.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367b.c @@ -565,7 +565,11 @@ static int rtl8367b_init_regs(struct rtl8366_smi *smi) count = ARRAY_SIZE(rtl8367c_initvals); if ((smi->rtl8367b_chip == RTL8367B_CHIP_RTL8367S_VB) && (smi->emu_vlanmc == NULL)) { smi->emu_vlanmc = kzalloc(sizeof(struct rtl8366_vlan_mc) * smi->num_vlan_mc, GFP_KERNEL); - dev_info(smi->parent, "alloc vlan mc emulator"); + if (!smi->emu_vlanmc) { + dev_err(smi->parent, "failed to allocate vlan mc emulator\n"); + return -ENOMEM; + } + dev_info(smi->parent, "alloc vlan mc emulator\n"); } break; default: @@ -1586,6 +1590,7 @@ static void rtl8367b_remove(struct platform_device *pdev) rtl8367b_switch_cleanup(smi); platform_set_drvdata(pdev, NULL); rtl8366_smi_cleanup(smi); + kfree(smi->emu_vlanmc); kfree(smi); } } |