net: moxa: fix UAF in moxart_mac_probe
Pavel Skripkin authored
commit c78eaeeb upstream.

In case of netdev registration failure the code path will
jump to init_fail label:

init_fail:
	netdev_err(ndev, "init failed\n");
	moxart_mac_free_memory(ndev);
irq_map_fail:
	free_netdev(ndev);
	return ret;

So, there is no need to call free_netdev() before jumping
to error handling path, since it can cause UAF or double-free
bug.

Fixes: 6c821bd9

 ("net: Add MOXA ART SoCs ethernet driver")
Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
aa92c87d
Name Last commit Last update
Documentation dt-bindings: i2c: at91: fix example for scl-gpios
LICENSES LICENSES: Add the CC-BY-4.0 license
arch arm64: dts: marvell: armada-37xx: move firmware node to generic dtsi file
block block: grab a device refcount in disk_uevent
certs Merge tag 'kbuild-v5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
crypto crypto: sm2 - fix a memory leak in sm2
drivers net: moxa: fix UAF in moxart_mac_probe
fs f2fs: Show casefolding support only when supported
include net: ipv6: fix return value of ip6_skb_dst_mtu
init sched/core: Initialize the idle task with preemption disabled
ipc ipc/mqueue, msg, sem: avoid relying on a stack reference past its expiry
kernel sched/fair: Fix CFS bandwidth hrtimer expiry type
lib lib/decompress_unlz4.c: correctly handle zero-padding around initrds.
mm mm/userfaultfd: fix uffd-wp special cases for fork()
net net: ip_tunnel: fix mtu calculation for ETHER tunnel devices
samples samples/bpf: Fix the error return code of xdp_redirect's main()
scripts kbuild: mkcompile_h: consider timestamp if KBUILD_BUILD_TIMESTAMP is set
security smackfs: restrict bytes count in smk_set_cipso()
sound ALSA: isa: Fix error return code in snd_cmi8330_probe()
tools perf tools: Fix pattern matching for same substring in different PMU type
usr .gitignore: prefix local generated files with a slash
virt KVM: mmio: Fix use-after-free Read in kvm_vm_ioctl_unregister_coalesced_mmio
.clang-format clang-format: Update with the latest for_each macro list
.cocciconfig scripts: add Linux .cocciconfig for coccinelle
.get_maintainer.ignore Opt out of scripts/get_maintainer.pl
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.