From patchwork Wed Sep 25 09:55:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 174348 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp402186ill; Wed, 25 Sep 2019 02:55:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+B66JGBzQIgiai6MVt6v02Juqz29zTjeUH3KYBEC1UVruNaYJlnq3GihsyiUVFB/88AL0 X-Received: by 2002:a2e:9748:: with SMTP id f8mr2208375ljj.167.1569405327372; Wed, 25 Sep 2019 02:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569405327; cv=none; d=google.com; s=arc-20160816; b=K+m3+X7tRNGI12G7XWRYXZ4DcgN0I/RudKwTyYlaUgkRgCSwDJeQQcHCNBcJRsoJxx OJrMrxBgAVFSKQDVJFKqwYgE2B0KO6+Hm44otKMVtUVEt+E+9ltXx0rRA/Mlou7z/9mB HNnwPqk7VETDEpKwn7iVVvNXCIeCUmL/wJJ98VHDutGuKG4SSAZs32PEos7IKaI+Aijj kLUWIfitAIP00BxXaNWFrCgA4MVBsrlv5QZQS/6OWMpXb+PtFR6zY+uZhmw4kdjhjOA+ Kxl+w4cDtwQixjMHLLDMy/MpVSLFCGLsGhtmM3S1YizuT8SyJisUJQm3YHBYumM+6kZj m8Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=DWhbUGv2lQeZO4jYvuR/nIX8VcsQRP/3s99PPL6K370=; b=Ar1kROeKpB9zFEB//e/aGBQFtpgs1udVTOlss4SjgM23+PbEzbNbeVTRziofx0o9CA 7JLrZZ8VuqN21KbZOBkJrcSm7kG22BtgGpuMJfONEsgo+VwTYMpVJ1Q0evy3mLBxIP55 v4FuBLEpMFPHMxYTDJTJgqm9wnSHcLMflS1KuhuGelaevX1coxrTs0B/dnvAlRHY7T9G 0EzglfVPWW+fb+Hvbl5rLr0IFII0I5Dssz7DBgtV3VTho0o7GA1a2I0gnCPZrQq+8rKR rB6zXs2MWn4QNgXr12hch1A4AIsCD4EvemQYNrXZwJj3mZ9QcNFRUENYvTvtvvZlzFNL lXtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q10EU45N; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si2899363eds.179.2019.09.25.02.55.27; Wed, 25 Sep 2019 02:55:27 -0700 (PDT) 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=@linaro.org header.s=google header.b=q10EU45N; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732768AbfIYJz0 (ORCPT + 26 others); Wed, 25 Sep 2019 05:55:26 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37732 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbfIYJz0 (ORCPT ); Wed, 25 Sep 2019 05:55:26 -0400 Received: by mail-pf1-f196.google.com with SMTP id y5so3088115pfo.4 for ; Wed, 25 Sep 2019 02:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DWhbUGv2lQeZO4jYvuR/nIX8VcsQRP/3s99PPL6K370=; b=q10EU45NTJwIJeYfgsOBdN94NNFG3fwiOLyu8Ix7i+TuDo3WIftED76Ja2vnuOZ5rh qgmTU6GXJaHLYtMrF1wV0dwXj61rzxSLCXubwBC3wO2v+J84vvhJoyfkrzkgkLMBDx0P gaNMRxZrXdRvGNO8WCQ2H84Jtw78GxePE1UxWdthzJtNwMbuPhan0oFMKBAbcRLIdqIf wrUOFwSm10824LM2VQZACB2CD0ZR3+oy5SoJtq4pHz/2sAg04gbbi7BWmkpa+GVSafvJ dAuGXkJHykPpnzfplGIaOccK6F41LMCUwyy1T+tSybzxhFYFPWUk4xVrzityIH3k36ZE hRWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DWhbUGv2lQeZO4jYvuR/nIX8VcsQRP/3s99PPL6K370=; b=YCW1mtJv/QcKk0tvghBp7KVoI4YM9mujNzeJYGfXI5wKyW73MMM1S4oUmFOPgKDGKv SzHBxUXJnOECzPI2ctfzltE2m16Li5MVe4hkU8qpjPrEcLeE2P+SfJ92eIlhZgCAPFn9 4mrDmXXo7wNgvY4hrUhKt6ackLuAmXuDIGvSUWB6cKSCm8niN2pT0KBfL7iReAI2CcRw 0vAx6R+wcvDncLGU6v2BPm1IgN/A9MQAuj8qxSooacxKHDmq69hMJiivLSGB0SupraJA 1Plfc51ReF7Paga8/iVFGHUIv7pO1ClXnVgyfQ5iIQiHaem9iDl/FUbdavXerInxnct3 q6OA== X-Gm-Message-State: APjAAAVXau0WJhi1Wu+1o5j8tcWlixcc1Rzq3SWm1zAr/oBwBAugEx+n PhL6uRcX9dMW5M4h0mDdSXysmg== X-Received: by 2002:a62:f249:: with SMTP id y9mr8759936pfl.147.1569405325359; Wed, 25 Sep 2019 02:55:25 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id i7sm2430831pjs.1.2019.09.25.02.55.21 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Sep 2019 02:55:24 -0700 (PDT) From: Baolin Wang To: stable@vger.kernel.org, sre@kernel.org Cc: david@lechnology.com, linux-pm@vger.kernel.org, arnd@arndb.de, baolin.wang@linaro.org, orsonzhai@gmail.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.19.y 3/3] power: supply: sysfs: ratelimit property read error message Date: Wed, 25 Sep 2019 17:55:03 +0800 Message-Id: <117b7b2d9bed2a288676f5614d8dd8d09746ab93.1569404757.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Lechner [Upstream commit 87a2b65fc855e6be50f791c2ebbb492541896827] This adds rate limiting to the message that is printed when reading a power supply property via sysfs returns an error. This will prevent userspace applications from unintentionally dDOSing the system by continuously reading a property that returns an error. Signed-off-by: David Lechner Signed-off-by: Sebastian Reichel Signed-off-by: Baolin Wang --- drivers/power/supply/power_supply_sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 5a2757a..5358a80 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -131,7 +131,8 @@ static ssize_t power_supply_show_property(struct device *dev, dev_dbg(dev, "driver has no data for `%s' property\n", attr->attr.name); else if (ret != -ENODEV && ret != -EAGAIN) - dev_err(dev, "driver failed to report `%s' property: %zd\n", + dev_err_ratelimited(dev, + "driver failed to report `%s' property: %zd\n", attr->attr.name, ret); return ret; }