From patchwork Mon Jan 16 20:41:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 91577 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp190350qgi; Mon, 16 Jan 2017 12:41:26 -0800 (PST) X-Received: by 10.84.194.37 with SMTP id g34mr53153310pld.105.1484599286769; Mon, 16 Jan 2017 12:41:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k129si22553801pgk.90.2017.01.16.12.41.26; Mon, 16 Jan 2017 12:41:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751040AbdAPUlZ (ORCPT + 7 others); Mon, 16 Jan 2017 15:41:25 -0500 Received: from mail-ot0-f194.google.com ([74.125.82.194]:36250 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750858AbdAPUlZ (ORCPT ); Mon, 16 Jan 2017 15:41:25 -0500 Received: by mail-ot0-f194.google.com with SMTP id 36so7425750otx.3; Mon, 16 Jan 2017 12:41:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=oCiAD3MS/z++JwKRUpjNZzpm0zjiG8wfRRv27dj3ydQ=; b=YYxM3SUNgTPS34QGxQ6IVWRwp4cSK0xHfkBEjhaneAmo4G/XPfYBQ1pcC9GANCtZ3p sCGxlOKL2aSHwx0C7Pt5MzII0hJ+RwgpYpDCzndzyOyxArxHMGNsdcys5dhLC15Jmnp+ 8+dwCCkKvvc5ohjInd8pgzqxh9YaodZoDigu9dyrB3uVLjxDjUorNHgPKQQtZEYlOjBT k9BjBPjvqho1tvqsIsTge4HrS03BmF5D3PT2Vwfj4DtTclQaEMXLCEdYpOyr6ZCc9CVX 0WY+PULQyUNu1rMkonWCePIF7xohhml9u1Fp5EE/Z/btpM0i3WgM48yBUxu1Xjgw7CY7 werA== X-Gm-Message-State: AIkVDXJ2qYvWfqEFweudWT+9xRowl9zXvxJqeWthHLSh2wupbDZXdB4zu7qQ9WKdkTsJog== X-Received: by 10.157.53.42 with SMTP id o39mr18792870otc.157.1484599284088; Mon, 16 Jan 2017 12:41:24 -0800 (PST) Received: from rob-hp-laptop.herring.priv (72-48-98-129.dyn.grandenetworks.net. [72.48.98.129]) by smtp.googlemail.com with ESMTPSA id v14sm1686881otv.0.2017.01.16.12.41.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jan 2017 12:41:23 -0800 (PST) From: Rob Herring To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Rowand Subject: [PATCH 1/2] of: fix of_device_get_modalias returned length when truncating buffers Date: Mon, 16 Jan 2017 14:41:21 -0600 Message-Id: <20170116204122.5858-1-robh@kernel.org> X-Mailer: git-send-email 2.10.1 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 --- drivers/of/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.10.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Greg Kroah-Hartman diff --git a/drivers/of/device.c b/drivers/of/device.c index fd5cfad7c403..bd620452f255 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] = '_'; } - return tsize; + return repend; } /**