Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5941299ybi;
        Wed, 12 Jun 2019 11:05:27 -0700 (PDT)
X-Google-Smtp-Source: APXvYqxV3ji6wSUhSUW869RLo25xgF6MWsvonoe84af6GoLtnUqRsPDT3z0OzC+vzDteGCJYOcOR
X-Received: by 2002:a17:90a:28e4:: with SMTP id f91mr427963pjd.99.1560362727655;
        Wed, 12 Jun 2019 11:05:27 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1560362727; cv=none;
        d=google.com; s=arc-20160816;
        b=F10ndkPRR2RNfa/rtK3tNGveFp6eJoKjLxg33ctK0UL7mpNdZPucKq6+mArUYbSKIZ
         2UsUqMdOXYnBgpqMLi4Gnj51CnVsulnMv4qSH00DBvl5KJPZXqaUpyGxIczV8XAQG4Nj
         OoMI9ouJ7oMmbnvSmm7y8wYYWxxBd3TxVwsbYd9wsvGEi8SNeuYl1PPqjLwQJ1DfCo4y
         b+6LP/TCuA/vFjegC1GuFi1w0Sdg8Qu6cxNLflUnCwSwl80DSXmFqL5BBqHeFQFi4MXN
         NoyGw0btpCg7RH3TVK97ambJwDonmJlOyWpfpkodhzvMqM0L1M/kP/FehZuMBkU0uCUP
         AN9Q==
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
         :message-id:date:subject:cc:to:from;
        bh=axgdTi9daKJriv+oESLEdY5xM2l66R7w4L8WWVtYGxI=;
        b=qxZ7apJvfjjl2tr4A0ZKxFA4q1XbiWg8gh0tdlBRxRzqKqdWUxrQqiUuiRarGUBeNm
         +YkXE+jV1eJ3OKcBhmS5BoHyB0ME3Fz9T6lK5I5DDmaQHFmiKPLFT3B225cP6XCnPFso
         YTiUWfJFoz7HlSv/Tdx71p70rebxfL+OmsCrrcvo1pFdkchsuwN90XDoa5jzTo+RUbQ7
         lT0v8vPqUEgJXo9Ma/LuSa8KRI5w9xh/cLquiVlyC7fnNy+YO6p0PznApsbR14DHY+u6
         WmzKmd3lCbaYsJHt+i1e+2aEfnmtfYJR3plKk5N4HzR/+fjbtKyK7dY6pao/xxLxPeL1
         RePQ==
ARC-Authentication-Results: i=1; mx.google.com;
       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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com
Return-Path: <linux-kernel-owner@vger.kernel.org>
Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67])
        by mx.google.com with ESMTP id m18si420556pjv.101.2019.06.12.11.05.12;
        Wed, 12 Jun 2019 11:05: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;
       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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S2409417AbfFLPxK (ORCPT <rfc822;fezhang.suse@gmail.com>
        + 99 others); Wed, 12 Jun 2019 11:53:10 -0400
Received: from bhuna.collabora.co.uk ([46.235.227.227]:46840 "EHLO
        bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
        with ESMTP id S2407173AbfFLPxJ (ORCPT
        <rfc822;linux-kernel@vger.kernel.org>);
        Wed, 12 Jun 2019 11:53:09 -0400
Received: from turingmachine.home (unknown [IPv6:2804:431:d719:d9b5:d711:794d:1c68:5ed3])
        (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
        (No client certificate requested)
        (Authenticated sender: tonyk)
        by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 57C692808F4;
        Wed, 12 Jun 2019 16:53:06 +0100 (BST)
From:   =?UTF-8?q?Andr=C3=A9=20Almeida?= <andrealmeid@collabora.com>
To:     linux-mm@kvack.org
Cc:     linux-kernel@vger.kernel.org, catalin.marinas@arm.com,
        kernel@collabora.com, akpm@linux-foundation.org,
        =?UTF-8?q?Andr=C3=A9=20Almeida?= <andrealmeid@collabora.com>
Subject: [PATCH v2 1/2] mm: kmemleak: change error at _write when kmemleak is disabled
Date:   Wed, 12 Jun 2019 12:52:30 -0300
Message-Id: <20190612155231.19448-1-andrealmeid@collabora.com>
X-Mailer: git-send-email 2.22.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Sender: linux-kernel-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

According to POSIX, EBUSY means that the "device or resource is busy",
and this can lead to people thinking that the file
`/sys/kernel/debug/kmemleak/` is somehow locked or being used by other
process. Change this error code to a more appropriate one.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
---
Hello,

This time I've added the mailing list, not only the maintainers.

Changes in v2:
- Remove pr_error.
- Replace EINVAL for EPERM, since the command isn't invalid, in fact, the
user don't have the permission to trigger commands when kmemleak is
disabled.
- Reword the commit message to be clearer the rationale behind the
patch.

 mm/kmemleak.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 9dd581d11565..848333a591fa 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1866,7 +1866,7 @@ static ssize_t kmemleak_write(struct file *file, const char __user *user_buf,
 	}
 
 	if (!kmemleak_enabled) {
-		ret = -EBUSY;
+		ret = -EPERM;
 		goto out;
 	}
 
-- 
2.22.0