linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Du Cheng <ducheng2@gmail.com>,
	Shannon Nelson <shannon.lee.nelson@gmail.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 5.10 087/104] ethernet: sun: niu: fix missing checks of niu_pci_eeprom_read()
Date: Mon, 24 May 2021 17:26:22 +0200	[thread overview]
Message-ID: <20210524152335.735652748@linuxfoundation.org> (raw)
In-Reply-To: <20210524152332.844251980@linuxfoundation.org>

From: Du Cheng <ducheng2@gmail.com>

commit e6e337708c22f80824b82d4af645f20715730ad0 upstream.

niu_pci_eeprom_read() may fail, so add checks to its return value and
propagate the error up the callstack.

An examination of the callstack up to niu_pci_eeprom_read shows that:

niu_pci_eeprom_read() // returns int
    niu_pci_vpd_scan_props() // returns int
        niu_pci_vpd_fetch() // returns *void*
            niu_get_invariants() // returns int

since niu_pci_vpd_fetch() returns void which breaks the bubbling up,
change its return type to int so that error is propagated upwards.

Signed-off-by: Du Cheng <ducheng2@gmail.com>
Cc: Shannon Nelson <shannon.lee.nelson@gmail.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210503115736.2104747-24-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/sun/niu.c |   34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -8097,6 +8097,8 @@ static int niu_pci_vpd_scan_props(struct
 		start += 3;
 
 		prop_len = niu_pci_eeprom_read(np, start + 4);
+		if (prop_len < 0)
+			return prop_len;
 		err = niu_pci_vpd_get_propname(np, start + 5, namebuf, 64);
 		if (err < 0)
 			return err;
@@ -8141,8 +8143,12 @@ static int niu_pci_vpd_scan_props(struct
 			netif_printk(np, probe, KERN_DEBUG, np->dev,
 				     "VPD_SCAN: Reading in property [%s] len[%d]\n",
 				     namebuf, prop_len);
-			for (i = 0; i < prop_len; i++)
-				*prop_buf++ = niu_pci_eeprom_read(np, off + i);
+			for (i = 0; i < prop_len; i++) {
+				err =  niu_pci_eeprom_read(np, off + i);
+				if (err < 0)
+					return err;
+				*prop_buf++ = err;
+			}
 		}
 
 		start += len;
@@ -8152,14 +8158,14 @@ static int niu_pci_vpd_scan_props(struct
 }
 
 /* ESPC_PIO_EN_ENABLE must be set */
-static void niu_pci_vpd_fetch(struct niu *np, u32 start)
+static int niu_pci_vpd_fetch(struct niu *np, u32 start)
 {
 	u32 offset;
 	int err;
 
 	err = niu_pci_eeprom_read16_swp(np, start + 1);
 	if (err < 0)
-		return;
+		return err;
 
 	offset = err + 3;
 
@@ -8168,12 +8174,14 @@ static void niu_pci_vpd_fetch(struct niu
 		u32 end;
 
 		err = niu_pci_eeprom_read(np, here);
+		if (err < 0)
+			return err;
 		if (err != 0x90)
-			return;
+			return -EINVAL;
 
 		err = niu_pci_eeprom_read16_swp(np, here + 1);
 		if (err < 0)
-			return;
+			return err;
 
 		here = start + offset + 3;
 		end = start + offset + err;
@@ -8181,9 +8189,12 @@ static void niu_pci_vpd_fetch(struct niu
 		offset += err;
 
 		err = niu_pci_vpd_scan_props(np, here, end);
-		if (err < 0 || err == 1)
-			return;
+		if (err < 0)
+			return err;
+		if (err == 1)
+			return -EINVAL;
 	}
+	return 0;
 }
 
 /* ESPC_PIO_EN_ENABLE must be set */
@@ -9274,8 +9285,11 @@ static int niu_get_invariants(struct niu
 		offset = niu_pci_vpd_offset(np);
 		netif_printk(np, probe, KERN_DEBUG, np->dev,
 			     "%s() VPD offset [%08x]\n", __func__, offset);
-		if (offset)
-			niu_pci_vpd_fetch(np, offset);
+		if (offset) {
+			err = niu_pci_vpd_fetch(np, offset);
+			if (err < 0)
+				return err;
+		}
 		nw64(ESPC_PIO_EN, 0);
 
 		if (np->flags & NIU_FLAGS_VPD_VALID) {



  parent reply	other threads:[~2021-05-24 16:00 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 15:24 [PATCH 5.10 000/104] 5.10.40-rc1 review Greg Kroah-Hartman
2021-05-24 15:24 ` [PATCH 5.10 001/104] firmware: arm_scpi: Prevent the ternary sign expansion bug Greg Kroah-Hartman
2021-05-24 15:24 ` [PATCH 5.10 002/104] openrisc: Fix a memory leak Greg Kroah-Hartman
2021-05-24 15:24 ` [PATCH 5.10 003/104] tee: amdtee: unload TA only when its refcount becomes 0 Greg Kroah-Hartman
2021-05-24 15:24 ` [PATCH 5.10 004/104] RDMA/siw: Properly check send and receive CQ pointers Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 005/104] RDMA/siw: Release xarray entry Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 006/104] RDMA/core: Prevent divide-by-zero error triggered by the user Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 007/104] RDMA/rxe: Clear all QP fields if creation failed Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 008/104] scsi: ufs: core: Increase the usable queue depth Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 009/104] scsi: qedf: Add pointer checks in qedf_update_link_speed() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 010/104] scsi: qla2xxx: Fix error return code in qla82xx_write_flash_dword() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 011/104] RDMA/mlx5: Recover from fatal event in dual port mode Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 012/104] RDMA/core: Dont access cm_id after its destruction Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 013/104] nvmet: remove unused ctrl->cqs Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 014/104] nvmet: fix memory leak in nvmet_alloc_ctrl() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 015/104] nvme-loop: fix memory leak in nvme_loop_create_ctrl() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 016/104] nvme-tcp: rerun io_work if req_list is not empty Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 017/104] nvme-fc: clear q_live at beginning of association teardown Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 018/104] platform/mellanox: mlxbf-tmfifo: Fix a memory barrier issue Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 019/104] platform/x86: intel_int0002_vgpio: Only call enable_irq_wake() when using s2idle Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 020/104] platform/x86: dell-smbios-wmi: Fix oops on rmmod dell_smbios Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 021/104] RDMA/mlx5: Fix query DCT via DEVX Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 022/104] RDMA/uverbs: Fix a NULL vs IS_ERR() bug Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 023/104] tools/testing/selftests/exec: fix link error Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 024/104] powerpc/pseries: Fix hcall tracing recursion in pv queued spinlocks Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 025/104] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 026/104] nvmet: seset ns->file when open fails Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 027/104] perf/x86: Avoid touching LBR_TOS MSR for Arch LBR Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 028/104] locking/lockdep: Correct calling tracepoints Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 029/104] locking/mutex: clear MUTEX_FLAGS if wait_list is empty due to signal Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 030/104] powerpc: Fix early setup to make early_ioremap() work Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 031/104] btrfs: avoid RCU stalls while running delayed iputs Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 032/104] cifs: fix memory leak in smb2_copychunk_range Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 033/104] misc: eeprom: at24: check suspend status before disable regulator Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 034/104] ALSA: dice: fix stream format for TC Electronic Konnekt Live at high sampling transfer frequency Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 035/104] ALSA: intel8x0: Dont update period unless prepared Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 036/104] ALSA: firewire-lib: fix amdtp_packet tracepoints event for packet_index field Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 037/104] ALSA: line6: Fix racy initialization of LINE6 MIDI Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 038/104] ALSA: dice: fix stream format at middle sampling rate for Alesis iO 26 Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 039/104] ALSA: firewire-lib: fix calculation for size of IR context payload Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 040/104] ALSA: usb-audio: Validate MS endpoint descriptors Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 041/104] ALSA: bebob/oxfw: fix Kconfig entry for Mackie d.2 Pro Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 042/104] ALSA: hda: fixup headset for ASUS GU502 laptop Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 043/104] Revert "ALSA: sb8: add a check for request_region" Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 044/104] ALSA: firewire-lib: fix check for the size of isochronous packet payload Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 045/104] ALSA: hda/realtek: reset eapd coeff to default value for alc287 Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 046/104] ALSA: hda/realtek: Add some CLOVE SSIDs of ALC293 Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 047/104] ALSA: hda/realtek: Fix silent headphone output on ASUS UX430UA Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 048/104] ALSA: hda/realtek: Add fixup for HP OMEN laptop Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 049/104] ALSA: hda/realtek: Add fixup for HP Spectre x360 15-df0xxx Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 050/104] uio_hv_generic: Fix a memory leak in error handling paths Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 051/104] Revert "rapidio: fix a NULL pointer dereference when create_workqueue() fails" Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 052/104] rapidio: handle create_workqueue() failure Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 053/104] Revert "serial: mvebu-uart: Fix to avoid a potential NULL pointer dereference" Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 054/104] nvme-tcp: fix possible use-after-completion Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 055/104] x86/sev-es: Move sev_es_put_ghcb() in prep for follow on patch Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 056/104] x86/sev-es: Invalidate the GHCB after completing VMGEXIT Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 057/104] x86/sev-es: Dont return NULL from sev_es_get_ghcb() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 058/104] x86/sev-es: Use __put_user()/__get_user() for data accesses Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 059/104] x86/sev-es: Forward page-faults which happen during emulation Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 060/104] drm/amdgpu: Fix GPU TLB update error when PAGE_SIZE > AMDGPU_PAGE_SIZE Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 061/104] drm/amdgpu: disable 3DCGCG on picasso/raven1 to avoid compute hang Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 062/104] drm/amdgpu: update gc golden setting for Navi12 Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 063/104] drm/amdgpu: update sdma " Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 064/104] powerpc/64s/syscall: Use pt_regs.trap to distinguish syscall ABI difference between sc and scv syscalls Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 065/104] powerpc/64s/syscall: Fix ptrace syscall info with " Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 066/104] mmc: sdhci-pci-gli: increase 1.8V regulator wait Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 067/104] xen-pciback: redo VF placement in the virtual topology Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 068/104] xen-pciback: reconfigure also from backend watch handler Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 069/104] ipc/mqueue, msg, sem: avoid relying on a stack reference past its expiry Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 070/104] dm snapshot: fix a crash when an origin has no snapshots Greg Kroah-Hartman
2021-05-25 11:36   ` Patch regression - " Mikulas Patocka
2021-05-25 11:52     ` Greg Kroah-Hartman
2021-05-25 11:58       ` Mikulas Patocka
2021-05-24 15:26 ` [PATCH 5.10 071/104] dm snapshot: fix crash with transient storage and zero chunk size Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 072/104] kcsan: Fix debugfs initcall return type Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 073/104] Revert "video: hgafb: fix potential NULL pointer dereference" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 074/104] Revert "net: stmicro: fix a missing check of clk_prepare" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 075/104] Revert "leds: lp5523: fix a missing check of return value of lp55xx_read" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 076/104] Revert "hwmon: (lm80) fix a missing check of bus read in lm80 probe" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 077/104] Revert "video: imsttfb: fix potential NULL pointer dereferences" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 078/104] Revert "ecryptfs: replace BUG_ON with error handling code" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 079/104] Revert "scsi: ufs: fix a missing check of devm_reset_control_get" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 080/104] Revert "gdrom: fix a memory leak bug" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 081/104] cdrom: gdrom: deallocate struct gdrom_unit fields in remove_gdrom Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 082/104] cdrom: gdrom: initialize global variable at init time Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 083/104] Revert "media: rcar_drif: fix a memory disclosure" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 084/104] Revert "rtlwifi: fix a potential NULL pointer dereference" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 085/104] Revert "qlcnic: Avoid " Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 086/104] Revert "niu: fix missing checks of niu_pci_eeprom_read" Greg Kroah-Hartman
2021-05-24 15:26 ` Greg Kroah-Hartman [this message]
2021-05-24 15:26 ` [PATCH 5.10 088/104] net: stmicro: handle clk_prepare() failure during init Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 089/104] scsi: ufs: handle cleanup correctly on devm_reset_control_get error Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 090/104] net: rtlwifi: properly check for alloc_workqueue() failure Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 091/104] ics932s401: fix broken handling of errors when word reading fails Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 092/104] leds: lp5523: check return value of lp5xx_read and jump to cleanup code Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 093/104] qlcnic: Add null check after calling netdev_alloc_skb Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 094/104] video: hgafb: fix potential NULL pointer dereference Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 095/104] vgacon: Record video mode changes with VT_RESIZEX Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 096/104] vt_ioctl: Revert VT_RESIZEX parameter handling removal Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 097/104] vt: Fix character height handling with VT_RESIZEX Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 098/104] tty: vt: always invoke vc->vc_sw->con_resize callback Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 099/104] drm/i915/gt: Disable HiZ Raw Stall Optimization on broken gen7 Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 100/104] openrisc: mm/init.c: remove unused memblock_region variable in map_ram() Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 101/104] x86/Xen: swap NX determination and GDT setup on BSP Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 102/104] nvme-multipath: fix double initialization of ANA state Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 103/104] rtc: pcf85063: fallback to parent of_node Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 104/104] x86/boot/compressed/64: Check SEV encryption in the 32-bit boot-path Greg Kroah-Hartman
2021-05-24 21:27 ` [PATCH 5.10 000/104] 5.10.40-rc1 review Fox Chen
2021-05-24 21:58 ` Florian Fainelli
2021-05-24 22:03 ` Shuah Khan
2021-05-25  7:22 ` Naresh Kamboju
2021-05-25 14:26 ` Sudip Mukherjee
2021-05-25 14:32 ` Pavel Machek
2021-05-25 21:26 ` Guenter Roeck
2021-05-26  1:00 ` Samuel Zou

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=20210524152335.735652748@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=ducheng2@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shannon.lee.nelson@gmail.com \
    --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).