From: Joel Granados <j.granados@samsung.com>
To: <mcgrof@kernel.org>
Cc: <linux-kselftest@vger.kernel.org>,
<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Joel Granados <j.granados@samsung.com>
Subject: [PATCH v2 1/8] parport: plug a sysctl register leak
Date: Fri, 16 Jun 2023 10:59:15 +0200 [thread overview]
Message-ID: <20230616085922.3066990-2-j.granados@samsung.com> (raw)
In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com>
parport registers two sysctl directories in the parport_proc_register
function but only one of them was getting unregistered in
parport_proc_unregister. Keep track of both sysctl table headers and
handle them together when (un)registering.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
drivers/parport/procfs.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index cbb1fb5127ce..0f2d2e1ee28e 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -257,14 +257,16 @@ PARPORT_MAX_SPINTIME_VALUE;
struct parport_sysctl_table {
- struct ctl_table_header *sysctl_header;
+ struct ctl_table_header *port_header;
+ struct ctl_table_header *devices_header;
struct ctl_table vars[12];
struct ctl_table device_dir[2];
};
static const struct parport_sysctl_table parport_sysctl_template = {
- .sysctl_header = NULL,
- {
+ .port_header = NULL,
+ .devices_header = NULL,
+ {
{
.procname = "spintime",
.data = NULL,
@@ -429,7 +431,6 @@ parport_default_sysctl_table = {
int parport_proc_register(struct parport *port)
{
struct parport_sysctl_table *t;
- struct ctl_table_header *devices_h;
char *tmp_dir_path;
size_t tmp_path_len, port_name_len;
int bytes_written, i, err = 0;
@@ -464,8 +465,8 @@ int parport_proc_register(struct parport *port)
err = -ENOENT;
goto exit_free_tmp_dir_path;
}
- devices_h = register_sysctl(tmp_dir_path, t->device_dir);
- if (devices_h == NULL) {
+ t->devices_header = register_sysctl(tmp_dir_path, t->device_dir);
+ if (t->devices_header == NULL) {
err = -ENOENT;
goto exit_free_tmp_dir_path;
}
@@ -478,8 +479,8 @@ int parport_proc_register(struct parport *port)
goto unregister_devices_h;
}
- t->sysctl_header = register_sysctl(tmp_dir_path, t->vars);
- if (t->sysctl_header == NULL) {
+ t->port_header = register_sysctl(tmp_dir_path, t->vars);
+ if (t->port_header == NULL) {
err = -ENOENT;
goto unregister_devices_h;
}
@@ -490,7 +491,7 @@ int parport_proc_register(struct parport *port)
return 0;
unregister_devices_h:
- unregister_sysctl_table(devices_h);
+ unregister_sysctl_table(t->devices_header);
exit_free_tmp_dir_path:
kfree(tmp_dir_path);
@@ -505,7 +506,8 @@ int parport_proc_unregister(struct parport *port)
if (port->sysctl_table) {
struct parport_sysctl_table *t = port->sysctl_table;
port->sysctl_table = NULL;
- unregister_sysctl_table(t->sysctl_header);
+ unregister_sysctl_table(t->devices_header);
+ unregister_sysctl_table(t->port_header);
kfree(t);
}
return 0;
--
2.30.2
next prev parent reply other threads:[~2023-06-16 8:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230616085926eucas1p10709e25a4c0246ed2b22da602f919b4e@eucas1p1.samsung.com>
2023-06-16 8:59 ` [PATCH v2 0/8] Remove child from struct ctl_table Joel Granados
[not found] ` <CGME20230616085927eucas1p265c6e3512e3102a7df507da9d3f1f094@eucas1p2.samsung.com>
2023-06-16 8:59 ` Joel Granados [this message]
[not found] ` <CGME20230616085930eucas1p2d1b7ee012df532b3dcf15f96cd2f8c18@eucas1p2.samsung.com>
2023-06-16 8:59 ` [PATCH v2 2/8] test_sysctl: Fix test metadata getters Joel Granados
[not found] ` <CGME20230616085932eucas1p1d3d120da7944fc06d714035043697e4d@eucas1p1.samsung.com>
2023-06-16 8:59 ` [PATCH v2 3/8] test_sysctl: Group node sysctl test under one func Joel Granados
[not found] ` <CGME20230616085935eucas1p2439375978f0ee33afd6310a9f8c5d07a@eucas1p2.samsung.com>
2023-06-16 8:59 ` [PATCH v2 4/8] test_sysctl: Add an unregister sysctl test Joel Granados
[not found] ` <CGME20230616085937eucas1p2128b2ddb3c01c887a606f376de850767@eucas1p2.samsung.com>
2023-06-16 8:59 ` [PATCH v2 5/8] test_sysctl: Add an option to prevent test skip Joel Granados
[not found] ` <CGME20230616085939eucas1p24e5c916a261653ce64bb65c7d12d2830@eucas1p2.samsung.com>
2023-06-16 8:59 ` [PATCH v2 6/8] test_sysclt: Test for registering a mount point Joel Granados
[not found] ` <CGME20230616085941eucas1p152b54db1511bfdd1afab32621aec847e@eucas1p1.samsung.com>
2023-06-16 8:59 ` [PATCH v2 7/8] sysctl: Remove debugging dump_stack Joel Granados
[not found] ` <CGME20230616085944eucas1p14e8491c53f5390064035de1ffb354c7a@eucas1p1.samsung.com>
2023-06-16 8:59 ` [PATCH v2 8/8] sysctl: replace child with an enumeration Joel Granados
2023-06-18 9:33 ` [PATCH v2 0/8] Remove child from struct ctl_table Luis Chamberlain
2023-06-19 7:32 ` Joel Granados
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230616085922.3066990-2-j.granados@samsung.com \
--to=j.granados@samsung.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mcgrof@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®