Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2058632rwd; Fri, 2 Jun 2023 04:23:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VpL4j2smaQHITzIFAu+fLyKiHFQ9Wtn11MMYg9ITlt0VR/lzLavavllHmnNZYOh9c0DYl X-Received: by 2002:a05:6a20:1602:b0:10b:c843:9522 with SMTP id l2-20020a056a20160200b0010bc8439522mr5316463pzj.20.1685705033427; Fri, 02 Jun 2023 04:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685705033; cv=none; d=google.com; s=arc-20160816; b=RP7PVHXFJcD1qSNsEi4IKRvWhnZLKuG3yjjC3hEcIBYiGtiy61KyoGWAmycfAKgdno 2Ffuilj7wWeKCLY2tJyQPDci6yK8nQT55C+iULydJwl5b8qMN8V/vi0DjxDBb0M4A9cH ThIUsS0V2gBJehcvIJ6Vb2kDobC4V69FV4Sfx4miQP4KNQPluMljIdZDTj+TJVCB/zF8 DCy179FZiS4iBiWsVr0TExtdaJ6+ZYrdcON0BzlKghbNNI3h69cGMpiE6LquSxSGCSWZ HYSd7a4spYTU2KEi5xM9/LFaxe9NNNYeS4pxso31nrcpE373XCxpV+RNOTwzM5m/kV3V 2DBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=dg1KPdqa1g30CQqgCK1VP5CwiQO47gFwHbWyH2hvLF4=; b=Wd4VuU1I0yUSQtAVMtAJwm41ZF+s9ZwrwHOg2f9akpqUT7T9qUWB9WoDCNpajZ62W4 AIxCZhpg5XATAEqP9GGNSJ9whO4fe8SoZhEswQ3AI6d3guu0jGCfiYGmQ7V1FrAI7OVQ iBea2ZlgTl/q9aKO4jiQ5YAWzWjPaN3C7CYH1oeviHfypzZAYayDN780ABsnu+pvLDWm RyYw+VrxWtQ//ZFgpY4dW3HyCGDHvI/ByoSTiO8J6zyqGYg0P3ngUIY/syrofAkjux1T cIs/AKoLGdOVQVDRRyfg/USeFpbOa4N4hlrFIXt+s9WU8I1L5bfrYlkotAQPG41SRTyv JPtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=A5l5Dp0A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv131-20020a632e89000000b0053f262d3e32si853818pgb.654.2023.06.02.04.23.39; Fri, 02 Jun 2023 04:23:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=A5l5Dp0A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234530AbjFBLHJ (ORCPT + 99 others); Fri, 2 Jun 2023 07:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235107AbjFBLHA (ORCPT ); Fri, 2 Jun 2023 07:07:00 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D218313E for ; Fri, 2 Jun 2023 04:06:43 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110642euoutp02f4f42ea2c575fd17332f6f652a4223a5~k0tvuC0eL3126731267euoutp02D for ; Fri, 2 Jun 2023 11:06:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230602110642euoutp02f4f42ea2c575fd17332f6f652a4223a5~k0tvuC0eL3126731267euoutp02D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704002; bh=dg1KPdqa1g30CQqgCK1VP5CwiQO47gFwHbWyH2hvLF4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=A5l5Dp0AsTr1RIc34FVHNsJfLaUAnmSusVxKX4qlpPDDurxAOdbh1gL/bxyZT60FW dRdjS4AmmB+5TM8/8NyzSsuCdKGehSeXb1pujSUbG5qikEDDFk6ZUNW3/MiShXO6cX CjZ9Ui6kS5VV9nwpGeUxyr6IFWJaId1SrKp8yUJw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602110642eucas1p25278f4b80e5bc361bc1250e3a0a178a9~k0tvex7YG0783007830eucas1p2J; Fri, 2 Jun 2023 11:06:42 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 49.67.11320.24DC9746; Fri, 2 Jun 2023 12:06:42 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602110641eucas1p1e2e92293c385e8083ed104dbb96aa68b~k0tvCWeV_0085500855eucas1p1d; Fri, 2 Jun 2023 11:06:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602110641eusmtrp19ef6e4a22f40bb673b99d0be0320a9a5~k0tvB3wJ52194821948eusmtrp1R; Fri, 2 Jun 2023 11:06:41 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-69-6479cd42acc8 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C3.A9.10549.14DC9746; Fri, 2 Jun 2023 12:06:41 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230602110641eusmtip19329dc84f1680badc901c2cba72579b5~k0tu5IEoL3230032300eusmtip19; Fri, 2 Jun 2023 11:06:41 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:41 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 1/8] parport: plug a sysctl register leak Date: Fri, 2 Jun 2023 13:06:31 +0200 Message-ID: <20230602110638.789426-2-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsWy7djPc7pOZytTDL4f5LPYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DK+Lt/L2vBCtGKKbu+MDcw XhbsYuTkkBAwkeg9OYm1i5GLQ0hgBaPEge4LTBDOF0aJNW9Ps0M4nxklNjYcYIZpmfEDpmU5 o8TK53fY4KpefV/LDOFsYZRoWf+IFaSFTUBH4vybO2DtIgLiEidOb2YEKWIWmMAo0bfuF0sX IweHsIClRO9bSxCTRUBF4uo/H5ByXgEbiSfr37JBbJaXa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mEBS4net5YgJouAisTVfz4g5bwCNhJP1r9lg1gm L9F2fTrYSE4BW4lDp8+AxYWAatafucAOUS8ocXLmExYQmxmovnnrbGYIW0Li4IsXzBBzlCUm rPsN9UCtxOe/zxgnMIrMQtI+C0n7LCTtCxiZVzGKpJYW56bnFhvqFSfmFpfmpesl5+duYgRG 1LZjPzfvYJz36qPeIUYmDsZDjBIczEoivEJh5SlCvCmJlVWpRfnxRaU5qcWHGE2B3pzILCWa nA+M6bySeEMzA1NDEzNLA1NLM2MlcV7Pgo5EIYH0xJLU7NTUgtQimD4mDk6pBqbJBevyHnhH Rb2W3iZ7I2nd0+43/8NXrijguFnDlf555kSvHunHriv3qIV6rWLMu3uqwFJMYL+TSwb7+eba Y7O3h7S+7fskMKOgIkx5Z4KlqsHb2g0G08pdsg0aVk82WeauGf591272Lc1xHx7oT9jzoTT9 fUZg3h7bqxEa6+Q/HvjxVOeJ+XOv5SuaGjLOLNlvynVmlxPvUuVW+wCd2eYzdUS2LpOYJVBw JW2KzI5zj289XvmvewvPsVaT/4d8K/v4yhQ+x9hNi2PsvSq87LBBgIcv+/LYg9Y+pseCxbia J700mpd7zNqOnd/zFg+rxpm5v/bvvNI9PTZm+rQAuSxtxxOmznckPP+kKc5QYVFiKc5INNRi LipOBADcb+IRMQMAAA== X-CMS-MailID: 20230602110641eucas1p1e2e92293c385e8083ed104dbb96aa68b X-Msg-Generator: CA X-RootMTR: 20230602110641eucas1p1e2e92293c385e8083ed104dbb96aa68b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110641eucas1p1e2e92293c385e8083ed104dbb96aa68b References: <20230602110638.789426-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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