Received: by 10.223.185.116 with SMTP id b49csp1090883wrg; Sat, 3 Mar 2018 15:18:11 -0800 (PST) X-Google-Smtp-Source: AG47ELv+zLg+aL2b1LyhOQDOg7TTI1r5NIAmc8BsOZud3gk1H5fKSL893rpOneSgPwgfSLbHFLNK X-Received: by 10.98.64.146 with SMTP id f18mr10486788pfd.30.1520119090939; Sat, 03 Mar 2018 15:18:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520119090; cv=none; d=google.com; s=arc-20160816; b=rDw0vONgYIyFtqw8ai3mRMhzmkdZnz8lkU9Lqde0i3d6o1rwnrdW8jmi0kOgdtnCer G0Y5/rwLVRPp/426/pXGh92f2NU0f29BAOrFyZ7MRhh2OUW9kunvp5K913shBzGnX8Wn rxeUyoRt83px/5mssGL100Bcibu05l5CeVjKKGshSmjqdXUZrRG4oLki4/VaNdiLYZrr /cD9qdA5men90b99+XKV7UAh2yZgNfTz1wzICQBv808DcJsK9NSdZW5TNxQrx1tTpwhE zw/TnhsyYdHO6WrvQhE2LZ0qxhp6+46mUoet07RMy5hxS0iChCCioU+6K+a+6TatYTuF frZA== 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=2cfIqcltUurXXgxbYMzQ1cCowP5IGCUA+eMgrMy3HyI=; b=wXwjU4m0T8D3I+IEhM31URoDhGnii+NHIo1sINe+AaFJTa+Zz0/D2kYNgIEDtC0hj1 hh8CsWURbsUl2MZGSpazmqODqgyVBraXuNnuj824e4kq3BpLv+HApx5TN6hWTFH5kgou kAU4e+RdqVc4QBdCfFysPYLK9jKYfzu/LhqR/1C0QbLR6MjsK+xbKNdc+ObOZPk43uYH xPl6rwKuiLzTsnrjTqjJ0kdZAJ6plv8SDuH3EXqFpHRaa0KTMjNBG5oXC7FxUcko8AJs kOkHKnJ2cJ2ukz8sLAFGGfKI92rFz26DcvqOwz5ODg/aB3gWmT+15OWOQK5ajqkzduNg Zjwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=a/p5DWqT; 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 f5si6147730pgr.330.2018.03.03.15.17.56; Sat, 03 Mar 2018 15:18:10 -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=a/p5DWqT; 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 S933535AbeCCXQq (ORCPT + 99 others); Sat, 3 Mar 2018 18:16:46 -0500 Received: from mail-cys01nam02on0114.outbound.protection.outlook.com ([104.47.37.114]:41081 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934858AbeCCWiN (ORCPT ); Sat, 3 Mar 2018 17:38:13 -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=2cfIqcltUurXXgxbYMzQ1cCowP5IGCUA+eMgrMy3HyI=; b=a/p5DWqTivFU4mPlPXZ7MH5rgb1bjaKxY9G2lNZJ4t65SZnXgecsMxIeeIcn2XsxAlUNQEY3MQr/5qGrkgP/li2Qa9GmF9Mo8pgfNmTcFU6/aFDt6FleKrOvaGtN+KEYONguNuNUKcJBAhO/JcF6R3Ys2vHEyqhewWKSWwZqruw= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB1067.namprd21.prod.outlook.com (52.132.149.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.2; Sat, 3 Mar 2018 22:38:08 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:38:08 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Rob Herring , Frank Rowand , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 023/115] of: fix of_device_get_modalias returned length when truncating buffers Thread-Topic: [PATCH AUTOSEL for 4.4 023/115] of: fix of_device_get_modalias returned length when truncating buffers Thread-Index: AQHTsz9OC/7TDueD2UiC/NEv98vMDQ== Date: Sat, 3 Mar 2018 22:31:01 +0000 Message-ID: <20180303223010.27106-23-alexander.levin@microsoft.com> References: <20180303223010.27106-1-alexander.levin@microsoft.com> In-Reply-To: <20180303223010.27106-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;MW2PR2101MB1067;7:XOL1Cx4sO6vWfshGNDUu5zQOjA7PShcKpOxzGBFJSB6IxpsBnfAmUop+TBd15qR4LAGsfMJII/0sQ3RFYpJdA1cGAeNCA7mhzAoMfL5C1YE2YcTbbNInLsjFE8juVnYC3rlWZyQaghU1TCq7zQJrsTd5aIllGpSKG3SXvkr31SCNo5TswN6LTlZ9c3+I81oDnMow1lj+PI4TWlUF1CEFLZEEA8ev+AFVFX1nKOz4vswJMIQ8gWAk5FyJo3eAKxUO x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 926837e2-19ea-475b-b63d-08d581576fdb x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB1067; x-ms-traffictypediagnostic: MW2PR2101MB1067: 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)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(3231220)(944501244)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:MW2PR2101MB1067;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB1067; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(396003)(366004)(376002)(39860400002)(39380400002)(346002)(199004)(189003)(4326008)(5250100002)(86362001)(1076002)(2501003)(110136005)(6666003)(81156014)(2906002)(8936002)(305945005)(81166006)(2950100002)(7736002)(10290500003)(26005)(186003)(3660700001)(478600001)(72206003)(107886003)(8676002)(3280700002)(59450400001)(2900100001)(39060400002)(76176011)(6116002)(25786009)(3846002)(102836004)(6506007)(5660300001)(97736004)(10090500001)(86612001)(106356001)(99286004)(6512007)(66066001)(316002)(53936002)(14454004)(105586002)(36756003)(6486002)(54906003)(6436002)(68736007)(22452003)(22906009)(217873001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB1067;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: joedtj0HoufFTZ2otf1j/F2BGLvA+gyRQAPxYfVVRS2F9SVwT52l+0XOYa6U1sH0L/LaPS7JOQZLIlSLEzjshgkkK77OrDaW/jBlwMPfdg9+iK4qLZOSP5mHt4eoiQObhM32XJ+/WdsYmy3jiI7YkOwY4vSK2j9HwplYKTn8VeQ= 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: 926837e2-19ea-475b-b63d-08d581576fdb X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:31:01.9790 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1067 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rob Herring [ Upstream commit bcf54d5385abaea9c8026aae6f4eeb348671a52d ] If the length of the modalias is greater than the buffer size, then the modalias is truncated. However the untruncated length is returned which will cause an error. Fix this to return the truncated length. If an error in the case was desired, then then we should just return -ENOMEM. The reality is no device will ever have 4KB of compatible strings to hit this case. Signed-off-by: Rob Herring Cc: Frank Rowand Signed-off-by: Sasha Levin --- drivers/of/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 97a280d50d6d..7c509bff9295 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -223,7 +223,7 @@ ssize_t of_device_get_modalias(struct device *dev, char= *str, ssize_t len) str[i] =3D '_'; } =20 - return tsize; + return repend; } EXPORT_SYMBOL_GPL(of_device_get_modalias); =20 --=20 2.14.1