Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3635233imu; Mon, 28 Jan 2019 08:11:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN6i/aVABuqJtXs7XSzW7kSVivHILyQDvgVSVZZL0NgLMqeTPWSGW1Oe7pX+uOsF8NPipeyI X-Received: by 2002:a17:902:2c83:: with SMTP id n3mr22595807plb.104.1548691899574; Mon, 28 Jan 2019 08:11:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691899; cv=none; d=google.com; s=arc-20160816; b=GOLMwg5aiehLfqjERVHCz2E4L5HKONBoXijXf2tmEddsO5y3pJrhvK9sw/xtsmJjnl eS8fJswI33OBvUpnzJZ5lDVId31fObvrq3Ar7MW+z/KueYHs1nCn+KJOtFsdwoc8l2KP QblpCl975jWe4UVRSgTeQADracnq5bRfrrCimzhS02sjk4pFpiIHOXLMNGetBiLoBcoP nq79ZBggOmKzkRRcjbYPeCpYyCN3GiVAIG6fQtaV9iPy0xIKP65Lj36Jjrs42/Obi+PR LnRuQgjFHsTYszUEdW4JTMQBDh/4Hv1LDoKf5n92EJXt4iAdh0hax2v1bu0OIVCU+DIK +T5g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q82lcQcioZsRkyzTS7UnVxeffnjxgSa3Jwnp8SV7e7c=; b=YRx8Ff2GqfQ41yIUt1TGONZI55/gaouw0ioyBKx+km340sGTIpRdK0ipohoUiaWLki ztf5axx9W12yvcOCon7wfKHvWMtlPTW/oV0oxbqdmrJxwjv08xsPAK2TaFqGXXwKxAge UHJWXPcMGGsvoVWjaOeMS2mjuwr7IyYv4edL7iHkrIvd7vdqz6mflQ+hGJDuRB2Wo+H0 AQX98WoaIlSH5IQ2oLSD409HJIW9BksHvBBKQ2OUZ8lLf3FCno88VSR01d9F3V65QgLx e6Z8kcD1tUK0b543Wcx4speR1Iv2HTs+7GiMibwct2K+74SzNrVX+tvnUpUkI94mfKgm uNZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YkpafIBf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v5si6079931pgh.510.2019.01.28.08.11.24; Mon, 28 Jan 2019 08:11:39 -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=YkpafIBf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732787AbfA1QK0 (ORCPT + 99 others); Mon, 28 Jan 2019 11:10:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:36274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732080AbfA1QKY (ORCPT ); Mon, 28 Jan 2019 11:10:24 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B8F221738; Mon, 28 Jan 2019 16:10:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691824; bh=2zemEJYtsJJ7GM4i4k5tRcHzbBkjfOZWmjYdTmImLjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YkpafIBfOI6w2m0RK+1isowzZaG2liS1YJO3y6jbIUSwrpc6I2rMrIqXu8ELLnpIk axB37E4Xy7igdg0r5iva1MtClpPZ08RspHgGVITXr8iwF8em9Z447B2/p6eNM9I3bM PTYcfnl+9FQZLBzJFg8rlUVSiPKsxgaUgFr9lsaY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kangjie Lu , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 229/258] niu: fix missing checks of niu_pci_eeprom_read Date: Mon, 28 Jan 2019 10:58:55 -0500 Message-Id: <20190128155924.51521-229-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kangjie Lu [ 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