Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2752326imj; Mon, 11 Feb 2019 07:59:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IaeuSDwOWdv4JrUI9K0KM8uzkQ1Tqsc2pTAkPX7h91Ncf3GHlAt9/NwfUy3q6P+WUXyyHm4 X-Received: by 2002:a62:6e07:: with SMTP id j7mr38270048pfc.135.1549900746836; Mon, 11 Feb 2019 07:59:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900746; cv=none; d=google.com; s=arc-20160816; b=tGutQuK+ZW16yEoGSeQQmu+SawqHJWanyB2fZxB1O9fpAZyN/2/v5aftG2VxBIVZzd c/NElPxeLRGChNL2559W09+qz+aMJlvCxPE5n+4otVH8K8D1wKsZSJVAoJOuQBB7naWp Cu4zhUoJhBfKMiCjepzhR9hVwQFwkCKWuvw7oORoGZ7yfC5IkKOND5Ql2pEtCHJFdWra au4pYq12g8pqfmKdJdqZW6eaQTMJf9GbwikAKdr/ez97nViW4rb/6VjiPy6YwPnsykTL hUTgSpCWLh6OFS9SDJnQmP5HfoG6a3i75AXvOmkRNyznW9Hv2YEkCsO+Dfql7wgaepV2 PMeA== 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=VMSYYvnowu7GBJYjld6p9ZvpX5+zq8FGMrJf+wCfCzM=; b=KA8AhpXpPjEYxVzP3onT6QWmAN99K8TByRjGs+lasiHGBRvMaX81a/KjZA9J5QjYXk VK96zJ9Vg9EXd3GowrZZK/ps41MhGbgBMrjsBkQSuo6W4mLFvTzYi5a9I+Gtao8DiyDv fTxJwy6hoSHIaseqnmPDNtMohvV9iQG54yLyiakkOOkIMV4+XBs3BW0Rm3nemZK+Mlmb PmwqETYay8ds1bkIooB+3kZKp/pf3wjItM6C2raUlQV2i9o84Zh0lvP3KZyr9Jw1jLcb EpzcnHxoTNAWikECmleiCZSdOrcAE05PS31QDGPUUevil8L2y0M/S8F74+AD2iPoDJeQ Nhgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2dVJb+h3; 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 p11si10306327plk.191.2019.02.11.07.58.50; Mon, 11 Feb 2019 07:59:06 -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=2dVJb+h3; 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 S1727705AbfBKP56 (ORCPT + 99 others); Mon, 11 Feb 2019 10:57:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:41056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730628AbfBKOdV (ORCPT ); Mon, 11 Feb 2019 09:33:21 -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 76790214DA; Mon, 11 Feb 2019 14:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895600; bh=8yr7WR8NzKEIdllMguyXHcHPMz1sZ3NoBvuVLzcBJYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2dVJb+h3uU+ds4dG1kdASp5mJQnB1Cwfj4FdlCdACnRMqW2uimzG3aOyVS4hRjrXH aT1/P/HA9OzmTsN1UDDRUbhqE+48pUZ3Jrea2hDjLMkNNtv401Ev1rC8UXRs+1HnxV RmZak/czRnQn+Qeme741F2j5lxYyS6YqHLKqvV1Y= 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.20 260/352] niu: fix missing checks of niu_pci_eeprom_read Date: Mon, 11 Feb 2019 15:18:07 +0100 Message-Id: <20190211141903.603792175@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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 9319d84bf49f..d84501441edd 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c @@ -8100,6 +8100,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; @@ -8144,8 +8146,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