Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2717777imj; Mon, 11 Feb 2019 07:26:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IbPd6X0ysFrDHom7YImjCPyUjzSdpqEYesElZ2AAPpnX3JHhSg4OJ63FT7358MOyB0bZROc X-Received: by 2002:a63:2209:: with SMTP id i9mr34190525pgi.325.1549898811467; Mon, 11 Feb 2019 07:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549898811; cv=none; d=google.com; s=arc-20160816; b=WIPaO07Dg3X4QrSoHvbT9HyYsoWNOnw5TvqS+7sYjsq013Mzolkok+cTmnkAKcfvEf qaeZkuaZ78SYHu64CxKp4irQ3CK7Pt3s9XzbGuHchgPcDThgZSIS7u0WDFxihHu76EuA NmFfzEXn/96r8VHB7amLFxNyuBfZYhpS7VYVBuhOBn1K+1Bd8YjEtSfuc46lVosF2tCp idFREKSYi/5nXxDOiBjzO+kHw1ZD5g2YtnQ9gfy+KG9hYPKYQ9kZ9xPx6hp2Vn0K+tMT NIJ0bOD0xpH0gFUJnG2GyfrSsn/M+pnWkoMkK3EBNy37L+PKSIdhenZogBYmQ6mH33Vq iwKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g0FO/lfuOz6P9aSjUPn57X/HZRXqW65jFb3MeRON2ho=; b=hvT/yhZXLeNketp9ZThgRwD3kCpdGWZYN/r9E6HmIBgegN1EAgjTQOmo8nfog6Z0xX vfppMHYzyiZwMQpMduRiOMbAVMdKvtIiOS2h8AM6W/3ZSvCzU7UxMbcLEhMkgeoQXHN+ 1ngxXAr7RB5GTe6ItDghY1yIjHYohr5VgLrXqhfPAhlhzRUWdOF8WW1DnVpe2CkVnGLp tKNrZWkHV187J3+Nm4SPs895/GrQtv8IBe3QnGUqqRXeQW3dr+8c2HGDR1342PWwDXi7 ebDCFePycs3sPZMYmB4sEoKgxXunaAx+bF3jBgHZiGJcvgFntaW3Y9k6A3V9EbLqrBzY nJZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Uopp9xy+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d17si625242pgl.484.2019.02.11.07.26.35; Mon, 11 Feb 2019 07:26:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Uopp9xy+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390125AbfBKPBI (ORCPT + 99 others); Mon, 11 Feb 2019 10:01:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:49066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390118AbfBKPBG (ORCPT ); Mon, 11 Feb 2019 10:01:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D1424206BA; Mon, 11 Feb 2019 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897265; bh=pxmZ9o5VfTl/BlFiUoQi5tFTZuuGDnM7LzjacSKzoNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uopp9xy+BLP4TIlngAubjuuWDx04eYO/RNNiheaxWVtWeBNvGa9coYjy4fgUyeYje pyi/fVpuGWsdf/nuN4Kdo6KOpcb6X0tZQ9lbVndr9oI1SbjeRfbmZCLVAPafhMfXnr v9N1BwjkhXYDRQRQEE65ViBwA3f5NsOHLX4VCnG8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Shannon Nelson , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 144/205] niu: fix missing checks of niu_pci_eeprom_read Date: Mon, 11 Feb 2019 15:19:02 +0100 Message-Id: <20190211141837.776187657@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 26fd962bde0b15e54234fe762d86bc0349df1de4 ] niu_pci_eeprom_read() may fail, so we should check its return value before using the read data. Signed-off-by: Kangjie Lu Acked-by: Shannon Nelson Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/sun/niu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index e92f41d20a2c..411a69bea1d4 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c @@ -8119,6 +8119,8 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end) 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; @@ -8163,8 +8165,12 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end) 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) + *prop_buf = err; + ++prop_buf; + } } start += len; -- 2.19.1