Received: by 10.223.185.116 with SMTP id b49csp5962065wrg; Wed, 7 Mar 2018 22:44:26 -0800 (PST) X-Google-Smtp-Source: AG47ELuMuZRXPOh7svWukieHMdMB75zFx7B+YfC9vNkWKklaZuAjjD+Vgh3PnkabPEYdGxTzTz2V X-Received: by 2002:a17:902:9002:: with SMTP id a2-v6mr22891807plp.412.1520491466068; Wed, 07 Mar 2018 22:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520491466; cv=none; d=google.com; s=arc-20160816; b=XUjxLWJAZN+fXY3lgXki0pqxBtLaUaWgKTf+vSETaZHBB+4iATJDtFcEGlh56nrzFR zvFHcGiT5067aiqQ4JPMygxfbF54+zuCKFaVK/y0jM2gCFA9oO2v6bDWKqd7EOGpVHVL +MjI0mFiE6sDVqxDfp9uFNuC+fifJmg8KKBYrOoQ9XJ0L1HfrWKwhjXdFo0L9XZDNSyW JhK2Bezk7n0y8rMnxtwmb4Ebl0rD2G1W2wMz3BqtCfte7IFefYSePaUZfG5J9II8p7F6 9FLqC3HNfm+XcY7Vc+LoaEthVs4NQB2tEnOPVaQ5TGmSyQQLpaQwO7l1m7+mx+dTafp1 snGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=HaW1yuNm2uewrXWELsTVgL7lJL8CaBauDC8hIMCK9lI=; b=tXzP6Lk/viS2luJRqpxsQPaC9TuAgiJZMpDeZOlkuaCC+P3utxkZLh26aS6Oa4nR3G zUUEp1+8FJe1qH06Wt+56TqFUFmzkkUDJqgEkk7kgo5stk2NOeZOfgykdn5jEoPtV9FH +Wk7xZYdEydqRXR/+qDd0cIiKWF0NU9QNCwvigwKezGQxAmso/KCoFsoRi7/jEw1SJBW umvGGDgTLkmsmwGl9GHF/csUVJ/W0MAQaXcmKeb1ivhTzghf3lMzX1BIP0ziHcNyfebc c4W/D3P07LnGjEeNUXhhtwVBD1nwinpRwzDZ0XIk9nS5XnJxrzkuDOaLhJHFlXCPIbT2 kHXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=egF9rD7O; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si15179248pfk.412.2018.03.07.22.44.11; Wed, 07 Mar 2018 22:44:26 -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=@microsoft.com header.s=selector1 header.b=egF9rD7O; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965243AbeCHE67 (ORCPT + 99 others); Wed, 7 Mar 2018 23:58:59 -0500 Received: from mail-by2nam03on0124.outbound.protection.outlook.com ([104.47.42.124]:6433 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935243AbeCHE6z (ORCPT ); Wed, 7 Mar 2018 23:58:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=HaW1yuNm2uewrXWELsTVgL7lJL8CaBauDC8hIMCK9lI=; b=egF9rD7Ofg2IALm3fGYsPgSO2i5srR8Z/NbvhjHdW/XN69Ecz84i2LtA2vr5emS5ELgrmOgpJnujEbRN034HOy3N/l101OxzVeAzAxcTnQqL8ELeFF9PM1thfZ3Vbh/oxrCARUofmmSPk39TplfV55fGand4aSfZcfJcYFgjhLc= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1080.namprd21.prod.outlook.com (52.132.130.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Thu, 8 Mar 2018 04:58:53 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:58:53 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Russell King , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 32/67] sfp: fix EEPROM reading in the case of non-SFF8472 SFPs Thread-Topic: [PATCH AUTOSEL for 4.14 32/67] sfp: fix EEPROM reading in the case of non-SFF8472 SFPs Thread-Index: AQHTtpn/Fia+7N/+V0ShiJmc+w6Yrg== Date: Thu, 8 Mar 2018 04:57:45 +0000 Message-ID: <20180308045641.7814-32-alexander.levin@microsoft.com> References: <20180308045641.7814-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045641.7814-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1080;20:jJsGK2447jSM1ZyeuuNJvUsZg5tjVn0QwNt4afovuBXzyILr/r70aXUCJIaXf8Ds3R4mRTBI7U85NLumciYN5HFb1bwAVkEe3zXk4l7eTv9Crq1DplSQWe/1e1h/JF4iQePHfJ63ynIALR6UbZt7OUQsslIo4MP/HEM5dgyNXUM= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d8dd61e6-aa91-4ce1-f382-08d584b14a5f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1080; x-ms-traffictypediagnostic: DM5PR2101MB1080: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(3231220)(944501244)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB1080;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1080; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(376002)(366004)(39380400002)(346002)(39860400002)(189003)(199004)(6116002)(1076002)(5250100002)(26005)(102836004)(2501003)(3846002)(59450400001)(186003)(6506007)(25786009)(3280700002)(4326008)(2906002)(68736007)(66066001)(86612001)(3660700001)(22452003)(6486002)(6436002)(14454004)(8676002)(81166006)(2900100001)(72206003)(81156014)(8936002)(478600001)(10090500001)(105586002)(10290500003)(53936002)(6512007)(6666003)(107886003)(2950100002)(106356001)(76176011)(316002)(7736002)(86362001)(36756003)(97736004)(54906003)(110136005)(5660300001)(99286004)(305945005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1080;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Deck4y4Pp1rLFQDfUFVf4xBmQNSKdti9ea8huxar3F8e4/tf8oVAcN7sPfcnkRHY8oU8x05fOjqDNRusLAqX4te7USaVHZgDtHHn2BhbVgK9h+htOzljuIVGto1FWU5bVnhdXRpAYg04043KZ0lgZJjL2CjghjNGiHLka8H2Auv+QwuqpaoI1Th9MHoAh3oP8BaE5xdY8jOkQWuuKgzMpFxd6A/jiAsduli9caHBEp2W6dJKKnRTd7nksc45pYTjK1XtfRnSWE0lKzgB0sfpkmhpRNW3x6EsWakSGmESj1Tk7YVdt5Sci7SXg5Geq3FVEi99zUVePedno6xO3oP91Q== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8dd61e6-aa91-4ce1-f382-08d584b14a5f X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:57:45.5706 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1080 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Russell King [ Upstream commit 2794ffc441dde3109804085dc745e8014a4de224 ] The EEPROM reading was trying to read from the second EEPROM address if we requested the last byte from the SFF8079 EEPROM, which caused a failure when the second EEPROM is not present. Discovered with a S-RJ01 SFP module. Fix this. Fixes: 73970055450e ("sfp: add SFP module support") Signed-off-by: Russell King Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/sfp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 8bf10aba7452..ddf184db9c45 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -667,20 +667,19 @@ static int sfp_module_eeprom(struct sfp *sfp, struct = ethtool_eeprom *ee, len =3D min_t(unsigned int, last, ETH_MODULE_SFF_8079_LEN); len -=3D first; =20 - ret =3D sfp->read(sfp, false, first, data, len); + ret =3D sfp_read(sfp, false, first, data, len); if (ret < 0) return ret; =20 first +=3D len; data +=3D len; } - if (first >=3D ETH_MODULE_SFF_8079_LEN && - first < ETH_MODULE_SFF_8472_LEN) { + if (first < ETH_MODULE_SFF_8472_LEN && last > ETH_MODULE_SFF_8079_LEN) { len =3D min_t(unsigned int, last, ETH_MODULE_SFF_8472_LEN); len -=3D first; first -=3D ETH_MODULE_SFF_8079_LEN; =20 - ret =3D sfp->read(sfp, true, first, data, len); + ret =3D sfp_read(sfp, true, first, data, len); if (ret < 0) return ret; } --=20 2.14.1