From patchwork Tue May 23 12:22:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13252177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0680C7EE23 for ; Tue, 23 May 2023 12:22:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236812AbjEWMWc (ORCPT ); Tue, 23 May 2023 08:22:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236669AbjEWMWb (ORCPT ); Tue, 23 May 2023 08:22:31 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 768E1109 for ; Tue, 23 May 2023 05:22:28 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230523122226euoutp01ba8b842fb32ce9051c4abffddd461049~hxTBO1uol1696116961euoutp01a for ; Tue, 23 May 2023 12:22:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230523122226euoutp01ba8b842fb32ce9051c4abffddd461049~hxTBO1uol1696116961euoutp01a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684844546; bh=PSEJhzKvpVyR/pqvYhGYpQKS9kejgYF7JkoWjFXjyTo=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=TsVPzu/gdpuIbDymwA0yuai6EvAGTVxv9zZCeCtZlweKsNZDXQ5/lO9FJ9Cb58xJa vogW/6zQr8+W3wesETNS2BzT//jkj+zZJJYT0kamB1udzFSYiupuMcLkjkpIEOSiBt pWXzowuq+qvYIm8zQKDZzo3xe/cUHuP6zPyfdzvQ= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230523122226eucas1p1e18f5acfe5110c795265c93f5efcee4f~hxTA3Iiwz2731327313eucas1p14; Tue, 23 May 2023 12:22:26 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 13.16.11320.200BC646; Tue, 23 May 2023 13:22:26 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230523122226eucas1p2bc0a2c060f01f460a11e90545f9da9aa~hxTAhQ5iA2886828868eucas1p2C; Tue, 23 May 2023 12:22:26 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230523122226eusmtrp25d4fcc81b8357666bf232d27fc9b313a~hxTAgcCMZ0635006350eusmtrp2a; Tue, 23 May 2023 12:22:26 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-7f-646cb0026184 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 8F.71.14344.100BC646; Tue, 23 May 2023 13:22:26 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230523122225eusmtip1067406525da12eb8ce270bbec5693002~hxTAU8pIc1745417454eusmtip10; Tue, 23 May 2023 12:22:25 +0000 (GMT) Received: from localhost (106.210.248.82) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 May 2023 13:22:25 +0100 From: Joel Granados To: CC: Christian Brauner , Kees Cook , Joel Granados , , , Iurii Zaikin , Alexander Viro , Sudip Mukherjee Subject: [PATCH v4 1/8] parport: Move magic number "15" to a define Date: Tue, 23 May 2023 14:22:13 +0200 Message-ID: <20230523122220.1610825-2-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230523122220.1610825-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.82] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNKsWRmVeSWpSXmKPExsWy7djPc7pMG3JSDB49k7R4ffgTo8WZ7lyL PXtPslhc3jWHzeLGhKeMFgdOT2G2OP/3OKvFsp1+DhwesxsusnjsnHWX3WPBplKPTas62Tw+ b5Lz2PTkLVMAWxSXTUpqTmZZapG+XQJXxoQDR9gKpnBV3H92grWBcTdHFyMHh4SAiUTjW90u Ri4OIYEVjBJrljxjhHC+MEps+z2NrYuRE8j5zChxfTMHiA3ScLflP1TRckaJe58uMcEVHXlX C5HYwijxdsENsASbgI7E+Td3mEFsEQFxiROnN4N1MwvsZJLo77wFtkJYwFli1dzDjCA2i4Cq xJtV58AaeAVsJdZv2cEGsVpeou36dLAaTgE7iUPP9rFC1AhKnJz5hAXEZgaqad46mxnClpA4 +OIFM0SvksTqrj9Qc2olTm25xQRyhITADw6JIxueQhW5SEz9PIEdwhaWeHV8C5QtI/F/53yo hsmMEvv/fWCHcFYzSixr/MoEUWUt0XLlCVSHo8SSNSD/g4KYT+LGW0GIi/gkJm2bzgwR5pXo aBOawKgyC8kPs5D8MAvJDwsYmVcxiqeWFuempxYb5aWW6xUn5haX5qXrJefnbmIEpp/T/45/ 2cG4/NVHvUOMTByMhxglOJiVRHhPlGenCPGmJFZWpRblxxeV5qQWH2KU5mBREufVtj2ZLCSQ nliSmp2aWpBaBJNl4uCUamAK+eJyzm7+1+/XTDP4FbkKKgUEzrEtcV1gXLzhdpASNwf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evT+5E/ fVvupeUfPelg5z533+RXz4/6mO7YfMvn7dtX/9I/fmudvXFPy6QFk1ZIxk2dVzMrVG9P/CKZ +h0hx/S3vTk1xfWGncVzFQMD9S+vjmt/CeLKXLitmcFPMmqnbVPilQ3PY0769Xn4rNGf842D P/Hl3+cqWzfFetZUH3kfveMbS/cxLcPnBRzMs8tcJ2pYzD0msz5rss2lye8Wvj+0pOZBXvOr FI2CJztq1+1atFA19GWaYHTgnI0HTtRe/uu9T7qkYPI0Ab6HAovWp15fJKHCYrRQVWliK9Oq R2wBVrKCB6wSZy6aa/yr6IfwRb3CiVm+657PPHpXvcywTYmlOCPRUIu5qDgRABQ9P3lYAwAA X-CMS-MailID: 20230523122226eucas1p2bc0a2c060f01f460a11e90545f9da9aa X-Msg-Generator: CA X-RootMTR: 20230523122226eucas1p2bc0a2c060f01f460a11e90545f9da9aa X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230523122226eucas1p2bc0a2c060f01f460a11e90545f9da9aa References: <20230523122220.1610825-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Put the size of a parport name behind a define so we can use it in other files. This is a preparation patch to be able to use this size in parport/procfs.c. Signed-off-by: Joel Granados Reviewed-by: Luis Chamberlain Signed-off-by: Luis Chamberlain --- drivers/parport/share.c | 2 +- include/linux/parport.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/parport/share.c b/drivers/parport/share.c index 62f8407923d4..2d46b1d4fd69 100644 --- a/drivers/parport/share.c +++ b/drivers/parport/share.c @@ -467,7 +467,7 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma, atomic_set(&tmp->ref_count, 1); INIT_LIST_HEAD(&tmp->full_list); - name = kmalloc(15, GFP_KERNEL); + name = kmalloc(PARPORT_NAME_MAX_LEN, GFP_KERNEL); if (!name) { kfree(tmp); return NULL; diff --git a/include/linux/parport.h b/include/linux/parport.h index a0bc9e0267b7..243c82d7f852 100644 --- a/include/linux/parport.h +++ b/include/linux/parport.h @@ -180,6 +180,8 @@ struct ieee1284_info { struct semaphore irq; }; +#define PARPORT_NAME_MAX_LEN 15 + /* A parallel port */ struct parport { unsigned long base; /* base address */ From patchwork Tue May 23 12:22:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13252178 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8615C7EE26 for ; Tue, 23 May 2023 12:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236816AbjEWMWe (ORCPT ); Tue, 23 May 2023 08:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234924AbjEWMWc (ORCPT ); Tue, 23 May 2023 08:22:32 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB166119 for ; Tue, 23 May 2023 05:22:29 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230523122228euoutp010dad4ed907fea311ecce435b2e199209~hxTCq44N91725117251euoutp01O for ; Tue, 23 May 2023 12:22:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230523122228euoutp010dad4ed907fea311ecce435b2e199209~hxTCq44N91725117251euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684844548; bh=Gl8w8aYUi8EdP/0mI8ukz2sgnZWD5EFjBiLLXuY7rlY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=vC+fR35q0VfVR8CfpZIrd0FRtKpO9lQxzwdlL5mu67rtwO2UlFBE4CGuLwVoAWCXy y3WeO4MJ8nfyrsywdi98wyPZmVqYxNF0pubgFN2Uv/7RIxXvYGQPkMGACoy/twVRJ0 WoRovUsB8ysc9KJgel+XorhpE9KpDVyhqx63bjCM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230523122228eucas1p18d511e1ddb871c6fda4dffb6aa6e195a~hxTCcbvID2697326973eucas1p19; Tue, 23 May 2023 12:22:28 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 40.C8.42423.400BC646; Tue, 23 May 2023 13:22:28 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230523122227eucas1p2ee83e872a9a3babd1196a286a34e175a~hxTCA79VE0063100631eucas1p2c; Tue, 23 May 2023 12:22:27 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230523122227eusmtrp2ba996f327f92df18bbe2b4a04a8311de~hxTCABXxt0635006350eusmtrp2k; Tue, 23 May 2023 12:22:27 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-e2-646cb0042352 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B6.BF.10549.300BC646; Tue, 23 May 2023 13:22:27 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230523122227eusmtip1cd14341a47651d0a13fc47c80a4eb32a~hxTB0pQ4h1739517395eusmtip1H; Tue, 23 May 2023 12:22:27 +0000 (GMT) Received: from localhost (106.210.248.82) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 May 2023 13:22:26 +0100 From: Joel Granados To: CC: Christian Brauner , Kees Cook , Joel Granados , , , Iurii Zaikin , Alexander Viro , Sudip Mukherjee Subject: [PATCH v4 2/8] parport: Remove register_sysctl_table from parport_proc_register Date: Tue, 23 May 2023 14:22:14 +0200 Message-ID: <20230523122220.1610825-3-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230523122220.1610825-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.82] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLKsWRmVeSWpSXmKPExsWy7djPc7osG3JSDGbMZLV4ffgTo8WZ7lyL PXtPslhc3jWHzeLGhKeMFgdOT2G2OP/3OKvFsp1+DhwesxsusnjsnHWX3WPBplKPTas62Tw+ b5Lz2PTkLVMAWxSXTUpqTmZZapG+XQJXRtu2WYwFDZoVO96eZ21gvK3YxcjJISFgIrH/YhNL FyMXh5DACkaJe7PWskE4XxglTk47zwrhfGaUuN87jxWm5dfkj0wQieWMEgePNCJU/fr3kB3C 2cIosbJlMRNIC5uAjsT5N3eYQWwRAXGJE6c3M4IUMQvsZJLo77wFtJGDQ1ggSuJ6QyFIDYuA qsT5Z6/YQGxeAVuJN69+MEKslpdouz4dzOYUsJM49GwfK0SNoMTJmU9YQGxmoJrmrbOZIWwJ iYMvXjBD9CpJrO76wwZh10qc2nIL7AUJgS8cEl9PvWaHSLhIPD12AupPYYlXx7dAxWUk/u+c D9UwmVFi/78P7BDOakaJZY1fmSCqrCVarjyB6nCU2DzrEzvIZxICfBI33gpCXMQnMWnbdGaI MK9ER5vQBEaVWUh+mIXkh1lIfljAyLyKUTy1tDg3PbXYMC+1XK84Mbe4NC9dLzk/dxMjM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3cvINx3quPeocYmTgY DzFKcDArifCeKM9OEeJNSaysSi3Kjy8qzUktPsRoCvTnRGYp0eR8YILIK4k3NDMwNTQxszQw tTQzVhLn9SzoSBQSSE8sSc1OTS1ILYLpY+LglGpgypQSd37A3LzXMGXiox3NXBxX2/gZdR13 5iy5dP8yd/y5zncacm1HuQ/eFLmxS7HMMtE1L0h6cVvZFj/3iUw/D+eFHFbap2C5OaG6b4q7 12+xA857f7+fWOybkRvibxhR8bHTquytge7mXTzhJRvST9nlGf/LXevbLf9YKTXQvujCw2V7 mgoWyplxyn7geFJ6x0NVQuT0wXsZ3Dbv5URfsx9ue73QUTfFMXLdIZ7ZU32Y9h3zM33+5ACX s960t/eEzTp3lwkZzu3Jfv17j/brRR6bOoWMAmYs3cFgM4GTI9xbpEX3g3bfkkeyFRwMqdse zLYL9555/WXHc552l+igSW8NS0Kb454yBwWwzFZiKc5INNRiLipOBAA7l7JBWAMAAA== X-CMS-MailID: 20230523122227eucas1p2ee83e872a9a3babd1196a286a34e175a X-Msg-Generator: CA X-RootMTR: 20230523122227eucas1p2ee83e872a9a3babd1196a286a34e175a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230523122227eucas1p2ee83e872a9a3babd1196a286a34e175a References: <20230523122220.1610825-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is part of the general push to deprecate register_sysctl_paths and register_sysctl_table. Register dev/parport/PORTNAME and dev/parport/PORTNAME/devices. Temporary allocation for name is freed at the end of the function. Remove all the struct elements that are no longer used in the parport_device_sysctl_template struct. Add parport specific defines that hide the base path sizes. To make sure the resulting directory structure did not change we made sure that `find /proc/sys/dev/ | sha1sum` was the same before and after the change. Signed-off-by: Joel Granados Reported-by: kernel test robot Closes: https://lore.kernel.org/r/202305150948.pHgIh7Ql-lkp@intel.com/ Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202305150948.pHgIh7Ql-lkp@intel.com/ Reviewed-by: Luis Chamberlain Signed-off-by: Luis Chamberlain --- drivers/parport/procfs.c | 93 ++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index d740eba3c099..28a37e0ef98c 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c @@ -32,6 +32,13 @@ #define PARPORT_MAX_TIMESLICE_VALUE ((unsigned long) HZ) #define PARPORT_MIN_SPINTIME_VALUE 1 #define PARPORT_MAX_SPINTIME_VALUE 1000 +/* + * PARPORT_BASE_* is the size of the known parts of the sysctl path + * in dev/partport/%s/devices/%s. "dev/parport/"(12), "/devices/"(9 + * and null char(1). + */ +#define PARPORT_BASE_PATH_SIZE 13 +#define PARPORT_BASE_DEVICES_PATH_SIZE 22 static int do_active_device(struct ctl_table *table, int write, void *result, size_t *lenp, loff_t *ppos) @@ -260,9 +267,6 @@ struct parport_sysctl_table { struct ctl_table_header *sysctl_header; struct ctl_table vars[12]; struct ctl_table device_dir[2]; - struct ctl_table port_dir[2]; - struct ctl_table parport_dir[2]; - struct ctl_table dev_dir[2]; }; static const struct parport_sysctl_table parport_sysctl_template = { @@ -305,7 +309,6 @@ static const struct parport_sysctl_table parport_sysctl_template = { .mode = 0444, .proc_handler = do_hardware_modes }, - PARPORT_DEVICES_ROOT_DIR, #ifdef CONFIG_PARPORT_1284 { .procname = "autoprobe", @@ -355,18 +358,6 @@ static const struct parport_sysctl_table parport_sysctl_template = { }, {} }, - { - PARPORT_PORT_DIR(NULL), - {} - }, - { - PARPORT_PARPORT_DIR(NULL), - {} - }, - { - PARPORT_DEV_DIR(NULL), - {} - } }; struct parport_device_sysctl_table @@ -473,11 +464,13 @@ parport_default_sysctl_table = { } }; - int parport_proc_register(struct parport *port) { struct parport_sysctl_table *t; - int i; + struct ctl_table_header *devices_h; + char *tmp_dir_path; + size_t tmp_path_len, port_name_len; + int bytes_written, i, err = 0; t = kmemdup(&parport_sysctl_template, sizeof(*t), GFP_KERNEL); if (t == NULL) @@ -485,28 +478,64 @@ int parport_proc_register(struct parport *port) t->device_dir[0].extra1 = port; - for (i = 0; i < 5; i++) - t->vars[i].extra1 = port; - t->vars[0].data = &port->spintime; - t->vars[5].child = t->device_dir; - - for (i = 0; i < 5; i++) - t->vars[6 + i].extra2 = &port->probe_info[i]; + for (i = 0; i < 5; i++) { + t->vars[i].extra1 = port; + t->vars[5 + i].extra2 = &port->probe_info[i]; + } - t->port_dir[0].procname = port->name; + port_name_len = strnlen(port->name, PARPORT_NAME_MAX_LEN); + /* + * Allocate a buffer for two paths: dev/parport/PORT and dev/parport/PORT/devices. + * We calculate for the second as that will give us enough for the first. + */ + tmp_path_len = PARPORT_BASE_DEVICES_PATH_SIZE + port_name_len; + tmp_dir_path = kzalloc(tmp_path_len, GFP_KERNEL); + if (!tmp_dir_path) { + err = -ENOMEM; + goto exit_free_t; + } - t->port_dir[0].child = t->vars; - t->parport_dir[0].child = t->port_dir; - t->dev_dir[0].child = t->parport_dir; + bytes_written = snprintf(tmp_dir_path, tmp_path_len, + "dev/parport/%s/devices", port->name); + if (tmp_path_len <= bytes_written) { + err = -ENOENT; + goto exit_free_tmp_dir_path; + } + devices_h = register_sysctl(tmp_dir_path, t->device_dir); + if (devices_h == NULL) { + err = -ENOENT; + goto exit_free_tmp_dir_path; + } - t->sysctl_header = register_sysctl_table(t->dev_dir); + tmp_path_len = PARPORT_BASE_PATH_SIZE + port_name_len; + bytes_written = snprintf(tmp_dir_path, tmp_path_len, + "dev/parport/%s", port->name); + if (tmp_path_len <= bytes_written) { + err = -ENOENT; + goto unregister_devices_h; + } + + t->sysctl_header = register_sysctl(tmp_dir_path, t->vars); if (t->sysctl_header == NULL) { - kfree(t); - t = NULL; + err = -ENOENT; + goto unregister_devices_h; } + port->sysctl_table = t; + + kfree(tmp_dir_path); return 0; + +unregister_devices_h: + unregister_sysctl_table(devices_h); + +exit_free_tmp_dir_path: + kfree(tmp_dir_path); + +exit_free_t: + kfree(t); + return err; } int parport_proc_unregister(struct parport *port) From patchwork Tue May 23 12:22:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13252179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF05FC7EE23 for ; Tue, 23 May 2023 12:22:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236827AbjEWMWh (ORCPT ); Tue, 23 May 2023 08:22:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236819AbjEWMWf (ORCPT ); Tue, 23 May 2023 08:22:35 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C8E118 for ; Tue, 23 May 2023 05:22:31 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230523122230euoutp02198fa97e7655cfe800e2792a3ca7937f~hxTE1F7JP1837818378euoutp02c for ; Tue, 23 May 2023 12:22:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230523122230euoutp02198fa97e7655cfe800e2792a3ca7937f~hxTE1F7JP1837818378euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684844550; bh=j+VnUb9JQ+kzpZedqCGPxjM1mMBuEtsRpF6yMVfDErY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=T49qgprvCGnQ3MLp1hms8PleBrGrtYoVAhE7XK1s+Fcwgyao2Vka+R3D0hyPrCrIn lGUkiUHXW1zpBuDAuy8hLy57+iu2ROAifKbBWUkgW2w1E1tjZwpfb4jnhyekctAu6U pO8h9jtIlyH0IcVMb3QI1nKVjcM70g2JkraF1ZM0= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230523122229eucas1p2be7fc25e0e5ea0a0ed20256ecdd12fe2~hxTD_LcMm0066500665eucas1p2w; Tue, 23 May 2023 12:22:29 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id BD.3E.37758.500BC646; Tue, 23 May 2023 13:22:29 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230523122229eucas1p2ea47c3d872cc7dd6f52de85e2e304b8c~hxTDm4hVA3086230862eucas1p2s; Tue, 23 May 2023 12:22:29 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230523122229eusmtrp2da5183f1bf8c7967c6891bf8833301f7~hxTDmC-kG0682106821eusmtrp2K; Tue, 23 May 2023 12:22:29 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-4a-646cb005461e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F8.BF.10549.500BC646; Tue, 23 May 2023 13:22:29 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230523122229eusmtip18bdb46ee0d6d94da7afbe5e83be05569~hxTDbWzc71745417454eusmtip13; Tue, 23 May 2023 12:22:29 +0000 (GMT) Received: from localhost (106.210.248.82) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 May 2023 13:22:28 +0100 From: Joel Granados To: CC: Christian Brauner , Kees Cook , Joel Granados , , , Iurii Zaikin , Alexander Viro , Sudip Mukherjee Subject: [PATCH v4 3/8] parport: Remove register_sysctl_table from parport_device_proc_register Date: Tue, 23 May 2023 14:22:15 +0200 Message-ID: <20230523122220.1610825-4-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230523122220.1610825-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.82] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNKsWRmVeSWpSXmKPExsWy7djP87qsG3JSDN7f1bF4ffgTo8WZ7lyL PXtPslhc3jWHzeLGhKeMFgdOT2G2OP/3OKvFsp1+DhwesxsusnjsnHWX3WPBplKPTas62Tw+ b5Lz2PTkLVMAWxSXTUpqTmZZapG+XQJXxvOpd9kLZkpVrFu0krWB8ZZoFyMnh4SAiUTn73fs ILaQwApGickPLLsYuYDsL4wSv++1M0E4nxklHj66wg7TcfbHKhaIxHJGiZkrnrPBVe3bd54J YtYWRolN06JAbDYBHYnzb+4wg9giAuISJ05vZgRpYBbYySTR33mLDSQhLJAosfXbBDCbRUBV ovnmT7AGXgFbiZs7TrNCrJaXaLs+nRHE5hSwkzj0bB8rRI2gxMmZT1hAbGagmuats5khbAmJ gy9eMEP0Kkms7vrDBmHXSpzacosJwv7PIbHuczKE7SJx8Ml+RghbWOLV8S1QL8tI/N85HxwW EgKTGSX2//vADuGsZpRY1vgVapK1RMuVJ1AdjhLvP2wC2swBZPNJ3HgrCHEQn8SkbdOhwrwS HW1CExhVZiF5YRaSF2YheWEBI/MqRvHU0uLc9NRi47zUcr3ixNzi0rx0veT83E2MwPRz+t/x rzsYV7z6qHeIkYmD8RCjBAezkgjvifLsFCHelMTKqtSi/Pii0pzU4kOM0hwsSuK82rYnk4UE 0hNLUrNTUwtSi2CyTBycUg1M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6mDg4pRqYStgk2l075E/2vFixdt57G4Hzrpum fhZZu/7ET/YJqbtFF1u8fLZ/m9pEl4Zv5ubz3h7ufbi86q1cfrD0sj07Z4bf+nP013L+6Pee XwN/OdUX3Cr1/7fhhPt0ZuaXc4uqu8uK3CdP5FHKvX7m3t78xWtO3dHed9A8kKUmW+Nknb/9 0QYFj9mfGNjOrQva8URx2z6FkhvTWDNUK05NWjblimN8+Iwv8RfuCi0szq9h/vHtwt6q6LVH pv70rH99dGKWVP8f76szTi05eU5OrpIpP7q6TI61LTX62NdHRe13Xr/pvHqbs3Wes1iVRt4t oeIZL02ff1iqUTFx/+OXz668ONOZOPXt6+srH+83tnp2f8FSJZbijERDLeai4kQAvmmoGFcD AAA= X-CMS-MailID: 20230523122229eucas1p2ea47c3d872cc7dd6f52de85e2e304b8c X-Msg-Generator: CA X-RootMTR: 20230523122229eucas1p2ea47c3d872cc7dd6f52de85e2e304b8c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230523122229eucas1p2ea47c3d872cc7dd6f52de85e2e304b8c References: <20230523122220.1610825-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is part of the general push to deprecate register_sysctl_paths and register_sysctl_table. We use a temp allocation to include both port and device name in proc. Allocated mem is freed at the end. The unused parport_device_sysctl_template struct elements that are not used are removed. Signed-off-by: Joel Granados Reported-by: kernel test robot Closes: https://lore.kernel.org/r/202305150948.pHgIh7Ql-lkp@intel.com/ Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202305150948.pHgIh7Ql-lkp@intel.com/ Reviewed-by: Luis Chamberlain Signed-off-by: Luis Chamberlain --- drivers/parport/procfs.c | 56 +++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index 28a37e0ef98c..22d211c95168 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c @@ -384,6 +384,7 @@ parport_device_sysctl_template = { .extra1 = (void*) &parport_min_timeslice_value, .extra2 = (void*) &parport_max_timeslice_value }, + {} }, { { @@ -394,22 +395,6 @@ parport_device_sysctl_template = { .child = NULL }, {} - }, - { - PARPORT_DEVICES_ROOT_DIR, - {} - }, - { - PARPORT_PORT_DIR(NULL), - {} - }, - { - PARPORT_PARPORT_DIR(NULL), - {} - }, - { - PARPORT_DEV_DIR(NULL), - {} } }; @@ -551,30 +536,53 @@ int parport_proc_unregister(struct parport *port) int parport_device_proc_register(struct pardevice *device) { + int bytes_written, err = 0; struct parport_device_sysctl_table *t; struct parport * port = device->port; + size_t port_name_len, device_name_len, tmp_dir_path_len; + char *tmp_dir_path; t = kmemdup(&parport_device_sysctl_template, sizeof(*t), GFP_KERNEL); if (t == NULL) return -ENOMEM; - t->dev_dir[0].child = t->parport_dir; - t->parport_dir[0].child = t->port_dir; - t->port_dir[0].procname = port->name; - t->port_dir[0].child = t->devices_root_dir; - t->devices_root_dir[0].child = t->device_dir; + port_name_len = strnlen(port->name, PARPORT_NAME_MAX_LEN); + device_name_len = strnlen(device->name, PATH_MAX); + + /* Allocate a buffer for two paths: dev/parport/PORT/devices/DEVICE. */ + tmp_dir_path_len = PARPORT_BASE_DEVICES_PATH_SIZE + port_name_len + device_name_len; + tmp_dir_path = kzalloc(tmp_dir_path_len, GFP_KERNEL); + if (!tmp_dir_path) { + err = -ENOMEM; + goto exit_free_t; + } + + bytes_written = snprintf(tmp_dir_path, tmp_dir_path_len, "dev/parport/%s/devices/%s", + port->name, device->name); + if (tmp_dir_path_len <= bytes_written) { + err = -ENOENT; + goto exit_free_path; + } - t->device_dir[0].procname = device->name; - t->device_dir[0].child = t->vars; t->vars[0].data = &device->timeslice; - t->sysctl_header = register_sysctl_table(t->dev_dir); + t->sysctl_header = register_sysctl(tmp_dir_path, t->vars); if (t->sysctl_header == NULL) { kfree(t); t = NULL; } device->sysctl_table = t; + + kfree(tmp_dir_path); return 0; + +exit_free_path: + kfree(tmp_dir_path); + +exit_free_t: + kfree(t); + + return err; } int parport_device_proc_unregister(struct pardevice *device) From patchwork Tue May 23 12:22:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13252180 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D828DC7EE26 for ; Tue, 23 May 2023 12:22:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236849AbjEWMWx (ORCPT ); Tue, 23 May 2023 08:22:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236820AbjEWMWf (ORCPT ); Tue, 23 May 2023 08:22:35 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8FD0119 for ; Tue, 23 May 2023 05:22:33 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230523122232euoutp026b022286d8e5be26949eebac23d8f8fe~hxTGq1Mcu1935319353euoutp02K for ; Tue, 23 May 2023 12:22:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230523122232euoutp026b022286d8e5be26949eebac23d8f8fe~hxTGq1Mcu1935319353euoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684844552; bh=8kGTrxkZCntknLjLjsK0zeP1J+VQ51ivte2ou+FOZlA=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=FK/UdKF1OaIEsOXkW6FoS+xt08om+EVf4h3E8VqTyRY60p/DB6mpIVkTvxemDln0A lge8QYTUC7knJ+UV82bR2OOtj09JEHVW8oQYGN6Lh2Ag14CfBHuvlUS5Q4GzoAxpkE TNee+tRV/UhJjiVNf58EmKlhoP/wO3BdNjOmPKpg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230523122232eucas1p173d4fa60efdbb3c391379bdb6d0ff71c~hxTGXd6JT2763627636eucas1p16; Tue, 23 May 2023 12:22:32 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E4.C8.42423.800BC646; Tue, 23 May 2023 13:22:32 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230523122231eucas1p25c90d2764372faba72095f5c43715ffb~hxTF9E9dC3085530855eucas1p2i; Tue, 23 May 2023 12:22:31 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230523122231eusmtrp236193b3b4609bcfc19a39755bdc6d544~hxTF8Qiry0682206822eusmtrp2O; Tue, 23 May 2023 12:22:31 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-f6-646cb008d548 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 7C.BF.10549.700BC646; Tue, 23 May 2023 13:22:31 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230523122231eusmtip224feb914c22ef14a02b814f5059c99a3~hxTFydkTX2166421664eusmtip2d; Tue, 23 May 2023 12:22:31 +0000 (GMT) Received: from localhost (106.210.248.82) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 May 2023 13:22:31 +0100 From: Joel Granados To: CC: Christian Brauner , Kees Cook , Joel Granados , , , Iurii Zaikin , Alexander Viro , Sudip Mukherjee Subject: [PATCH v4 4/8] parport: Remove register_sysctl_table from parport_default_proc_register Date: Tue, 23 May 2023 14:22:16 +0200 Message-ID: <20230523122220.1610825-5-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230523122220.1610825-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.82] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDKsWRmVeSWpSXmKPExsWy7djPc7ocG3JSDGafFLR4ffgTo8WZ7lyL PXtPslhc3jWHzeLGhKeMFgdOT2G2OP/3OKvFsp1+DhwesxsusnjsnHWX3WPBplKPTas62Tw+ b5Lz2PTkLVMAWxSXTUpqTmZZapG+XQJXxozbx1kKFvFWnO6/w9jA2MrdxcjJISFgIvFp4VaW LkYuDiGBFYwS0xeugHK+MEqcejabDcL5zCjRdHYOkMMB1jL5tDNEfDmjxO4pfxGK/i3+wwIy V0hgC6NES6M2iM0moCNx/s0dZhBbREBc4sTpzYwgDcwCO5kk+jtvsYEkhAWSJM6duQhmswio Slx58h/M5hWwlfj47iAbxLHyEm3XpzOC2JwCdhKHnu1jhagRlDg58wnYYmagmuats5khbAmJ gy9eMEP0Kkms7voDNadW4tSWW0wgR0gI/OCQWHfwI1SRi8SDj/OZIGxhiVfHt7BD2DIS/3fO h2qYzCix/98HdghnNaPEssavUB3WEi1XnkB1OEq0Np9mhgQYn8SNt4IQF/FJTNo2HSrMK9HR JjSBUWUWkh9mIflhFpIfFjAyr2IUTy0tzk1PLTbMSy3XK07MLS7NS9dLzs/dxAhMQKf/Hf+0 g3Huq496hxiZOBgPMUpwMCuJ8J4oz04R4k1JrKxKLcqPLyrNSS0+xCjNwaIkzqttezJZSCA9 s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QzVhLn9SzoSBQSSE8sSc1OTS1ILYLpY+LglGpgWnX22KmJIiZ+XP9r35Rf0Wz+9ffh hvC9E17kNN3Ynbpl+4Qg/wiNwlldk9Ze86mQqZw0y7OeM/CHU7qz358Pipp6sWdYfmr+nR/q cpwjeVtZ4cNsN01D9b7LGiXp0Zm/mOMO1UaLzO9s5yxuCvsgGyonGbKjplQ81imH1zBaRM7K LfbfVcn/28UlzVbUxp1f5njW8NeJvlanuVN1mzrvluxYXL9I7H7XCzvXtHdR+vuk9mc/mTfh 9R72t3d/6dr5h85+OOOmovBtyX3n9L22ryj1XLa0ymDl8cr4zsK0qkU/W9eeDhF989bxysbl TXVbvZfrf+5gstqffWvS7n2r77y35VsSeOwD7+rpsy+HKrEUZyQaajEXFScCAHcZCflXAwAA X-CMS-MailID: 20230523122231eucas1p25c90d2764372faba72095f5c43715ffb X-Msg-Generator: CA X-RootMTR: 20230523122231eucas1p25c90d2764372faba72095f5c43715ffb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230523122231eucas1p25c90d2764372faba72095f5c43715ffb References: <20230523122220.1610825-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is part of the general push to deprecate register_sysctl_paths and register_sysctl_table. Simply change the full path "dev/parport/default" to point to an already existing set of table entries (vars). We also remove the unused elements from parport_default_table. To make sure the resulting directory structure did not change we made sure that `find /proc/sys/dev/ | sha1sum` was the same before and after the change. Signed-off-by: Joel Granados Reviewed-by: Luis Chamberlain Signed-off-by: Luis Chamberlain --- drivers/parport/procfs.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index 22d211c95168..1a26918d2cc8 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c @@ -430,22 +430,6 @@ parport_default_sysctl_table = { .extra2 = (void*) &parport_max_spintime_value }, {} - }, - { - { - .procname = "default", - .mode = 0555, - .child = parport_default_sysctl_table.vars - }, - {} - }, - { - PARPORT_PARPORT_DIR(parport_default_sysctl_table.default_dir), - {} - }, - { - PARPORT_DEV_DIR(parport_default_sysctl_table.parport_dir), - {} } }; @@ -601,7 +585,7 @@ static int __init parport_default_proc_register(void) int ret; parport_default_sysctl_table.sysctl_header = - register_sysctl_table(parport_default_sysctl_table.dev_dir); + register_sysctl("dev/parport/default", parport_default_sysctl_table.vars); if (!parport_default_sysctl_table.sysctl_header) return -ENOMEM; ret = parport_bus_init(); From patchwork Tue May 23 12:22:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13252181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2982C7EE23 for ; Tue, 23 May 2023 12:22:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236864AbjEWMWz (ORCPT ); Tue, 23 May 2023 08:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236824AbjEWMWh (ORCPT ); Tue, 23 May 2023 08:22:37 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A82711F for ; Tue, 23 May 2023 05:22:35 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230523122234euoutp01b9cd0018141c5403163a66d2be7ced7a~hxTH8Xg-U1724917249euoutp01W for ; Tue, 23 May 2023 12:22:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230523122234euoutp01b9cd0018141c5403163a66d2be7ced7a~hxTH8Xg-U1724917249euoutp01W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684844554; bh=QqhHAxqdZ9zwu193bF6IzoCs6DWDxorB5tYMiEmfePM=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=RPx54jD6tED1Tft6UIeXuw/GhU8Q5UFG3cFrROA6OtLM33S1bZ8H8xbhiUh4OGeej CdycuRWhzxL9pSUaYH4HxTyGbVo4IS4A/61Ad14oh6lnuKC5t1rz2VVTuL5eFR6o/T oT5ntZBeVi74DGnkklqwkIOK7ZNlyYfGjL+nMiwE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230523122233eucas1p19b3effbf7c26fea6a587059aa3ffd7dc~hxTHrDLwU1810218102eucas1p1V; Tue, 23 May 2023 12:22:33 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 4B.16.11320.900BC646; Tue, 23 May 2023 13:22:33 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230523122233eucas1p1cb488b94dc2449b3bd0314b1f536a6e9~hxTHWdCVh2731327313eucas1p1-; Tue, 23 May 2023 12:22:33 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230523122233eusmtrp26992cefa0f96faee69ec101d2242b608~hxTHVx4bn0682206822eusmtrp2T; Tue, 23 May 2023 12:22:33 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-a0-646cb009b381 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 9D.BF.10549.900BC646; Tue, 23 May 2023 13:22:33 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230523122233eusmtip10cbbd9f4c983e0e1296a2d4a9227bbe4~hxTHMp4Nr0731007310eusmtip1U; Tue, 23 May 2023 12:22:33 +0000 (GMT) Received: from localhost (106.210.248.82) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 May 2023 13:22:32 +0100 From: Joel Granados To: CC: Christian Brauner , Kees Cook , Joel Granados , , , Iurii Zaikin , Alexander Viro , Sudip Mukherjee Subject: [PATCH v4 5/8] parport: Removed sysctl related defines Date: Tue, 23 May 2023 14:22:17 +0200 Message-ID: <20230523122220.1610825-6-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230523122220.1610825-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.82] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDKsWRmVeSWpSXmKPExsWy7djPc7qcG3JSDO6917R4ffgTo8WZ7lyL PXtPslhc3jWHzeLGhKeMFgdOT2G2OP/3OKvFsp1+DhwesxsusnjsnHWX3WPBplKPTas62Tw+ b5Lz2PTkLVMAWxSXTUpqTmZZapG+XQJXxu3pH5gLDnJWHDlwia2BcRt7FyMnh4SAicSunX9Z QWwhgRWMElvXs3QxcgHZXxglTs+czAjhfGaUWDPvNFzHqvP7mSASyxkluk/1McFVnTvxnQ1i 1hZGiQ89jCA2m4COxPk3d5hBbBEBcYkTpzeDjWUW2Mkk0d95C6xBWMBe4vrHf2BFLAKqEiv6 l4PZvAK2Eru6VrJCrJaXaLs+HWwop4CdxKFn+1ghagQlTs58wgJiMwPVNG+dzQxhS0gcfPGC GaJXSWJ11x82CLtW4tSWW2BXSwh84ZB4PW8C1AIXibMf/0A1CEu8Or4F6mc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Fn+8Di QkA1ra82sULUC0qcnPmEBcRmBqpv3jqbGcKWkDj44gUzxBwlidVdf9gg7FqJz3+fMU5gFJmF pH0WkvZZSNoXMDKvYhRJLS3OTc8tNtQrTswtLs1L10vOz93ECIzPbcd+bt7BOO/VR71DjEwc jIcYJTiYlUR4T5RnpwjxpiRWVqUW5ccXleakFh9iNAX6cyKzlGhyPjBB5JXEG5oZmBqamFka mFqaGSuJ83oWdCQKCaQnlqRmp6YWpBbB9DFxcEo1MGX8FtBy8lgfUhPL9Obp96Ztea9k/PKv 6i3lWXijVyBYcP3mDVqOaxTT1/X/WCGSV/p4aXO9+NUJ3i+V7wttVPYTCHgQ+Xnxmb8nedNd 8wW6NZmvzP9f4TLl76bWXsH5EpEnG8/vLldRc3K0FTFpl08W2nVHO9anwLc/Z6lf7j/JiZt/ Cf5o/fTx0HSZ4nPP9VZvrxPK3NGg/CDtqN8CC7uUC7P+LXvMtfNS7QJXN6WZHndYljAK9/2J O8XpmLxVY6sWQ87dnFksPKwTi+T91xmxJxvJKPhPXfzaxj/+VHuvtlCq6Ptes8OG29LfTnmS 07/0gixfmjtHyM/+4qkKoS2CqkEtivkPT9oaS9srsRRnJBpqMRcVJwIA+pBZ+FgDAAA= X-CMS-MailID: 20230523122233eucas1p1cb488b94dc2449b3bd0314b1f536a6e9 X-Msg-Generator: CA X-RootMTR: 20230523122233eucas1p1cb488b94dc2449b3bd0314b1f536a6e9 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230523122233eucas1p1cb488b94dc2449b3bd0314b1f536a6e9 References: <20230523122220.1610825-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The partport driver used to rely on defines to include different directories in sysctl. Now that we have made the transition to register_sysctl from regsiter_sysctl_table, they are no longer needed. Signed-off-by: Joel Granados Reviewed-by: Luis Chamberlain Signed-off-by: Luis Chamberlain --- drivers/parport/procfs.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index 1a26918d2cc8..cbb1fb5127ce 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c @@ -243,13 +243,6 @@ do { \ return 0; } -#define PARPORT_PORT_DIR(CHILD) { .procname = NULL, .mode = 0555, .child = CHILD } -#define PARPORT_PARPORT_DIR(CHILD) { .procname = "parport", \ - .mode = 0555, .child = CHILD } -#define PARPORT_DEV_DIR(CHILD) { .procname = "dev", .mode = 0555, .child = CHILD } -#define PARPORT_DEVICES_ROOT_DIR { .procname = "devices", \ - .mode = 0555, .child = NULL } - static const unsigned long parport_min_timeslice_value = PARPORT_MIN_TIMESLICE_VALUE; From patchwork Tue May 23 12:22:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13252182 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C16A0C7EE2A for ; Tue, 23 May 2023 12:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236638AbjEWMW5 (ORCPT ); Tue, 23 May 2023 08:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236830AbjEWMWi (ORCPT ); Tue, 23 May 2023 08:22:38 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF35118 for ; Tue, 23 May 2023 05:22:36 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230523122235euoutp02bc9529660297c7f85948aa85bcdff46b~hxTJVAQln1933219332euoutp02Q for ; Tue, 23 May 2023 12:22:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230523122235euoutp02bc9529660297c7f85948aa85bcdff46b~hxTJVAQln1933219332euoutp02Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684844555; bh=v2sIuTREWESn0gsMOClVzbRDY2pax45rUY1W/tjn7s4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=D4TtrJVdeWPayDfy7Y2mYgm5l3S8Rw83j0YPi+mqRwcosLmJfrmmipxRIY6UI6FT0 mXrbnTtAF57ctb4P1iO2VDA36thze1OatPOoz0vCSLMzwPtHHzlXWTbsu3QEylT2w5 PLhHsBsB2PiDWZQJ5YcQ46vUXRu3yng5zhmb6294= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230523122235eucas1p1381da8014c498ee425898795449b6a5f~hxTJDyHyG2656126561eucas1p1N; Tue, 23 May 2023 12:22:35 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id FC.16.11320.B00BC646; Tue, 23 May 2023 13:22:35 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230523122235eucas1p1398322259883bb53846e3445d7fd1cc6~hxTI07Co41810218102eucas1p1X; Tue, 23 May 2023 12:22:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230523122235eusmtrp2e8da0bab32b20140f5290240dec198ba~hxTI0YfQ-0682106821eusmtrp2Y; Tue, 23 May 2023 12:22:35 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-a6-646cb00b9963 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 39.81.14344.A00BC646; Tue, 23 May 2023 13:22:34 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230523122234eusmtip1e769166eaaa94c9881830fb125f45785~hxTIpP3Oo1420014200eusmtip11; Tue, 23 May 2023 12:22:34 +0000 (GMT) Received: from localhost (106.210.248.82) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 May 2023 13:22:34 +0100 From: Joel Granados To: CC: Christian Brauner , Kees Cook , Joel Granados , , , Iurii Zaikin , Alexander Viro , Sudip Mukherjee Subject: [PATCH v4 6/8] sysctl: stop exporting register_sysctl_table Date: Tue, 23 May 2023 14:22:18 +0200 Message-ID: <20230523122220.1610825-7-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230523122220.1610825-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.82] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLKsWRmVeSWpSXmKPExsWy7djP87rcG3JSDJZ08Fu8PvyJ0eJMd67F nr0nWSwu75rDZnFjwlNGiwOnpzBbnP97nNVi2U4/Bw6P2Q0XWTx2zrrL7rFgU6nHplWdbB6f N8l5bHrylimALYrLJiU1J7MstUjfLoEr43n/QpaCzQoV/96sZG1gfCzZxcjJISFgItG3+AJ7 FyMXh5DACkaJuRsPMEM4XxgldnXfZ4JwPjNK3Gg7xwzTcunjeUaIxHJGiS3bDrDDVV280ArV v4VR4s+PHawgLWwCOhLn39wBaxcREJc4cXozWDuzwE4mif7OW2wgCWEBF4m2s68YQWwWAVWJ nict7CA2r4CtxL5XbSwQu+Ul2q5PB6vhFLCTOPRsHytEjaDEyZlPwGqYgWqat85m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JE4/+YOmC0iIC5x4vRmsLHMAtuZ JCb83cUGkhAWcJFoO/uKEcRmEVCV6HnSwg5i8wrYSux71cYCsU5eou36dLAaTgE7iUPP9oGd IQRU0/pqEytEvaDEyZlPwOqZgeqbt85mhrAlJA6+eMEMMUdJYnXXHzYIu1bi899njBMYRWYh aZ+FpH0WkvYFjMyrGEVSS4tz03OLjfSKE3OLS/PS9ZLzczcxAuNz27GfW3Ywrnz1Ue8QIxMH 4yFGCQ5mJRHeE+XZKUK8KYmVValF+fFFpTmpxYcYTYH+nMgsJZqcD0wQeSXxhmYGpoYmZpYG ppZmxkrivJ4FHYlCAumJJanZqakFqUUwfUwcnFINTHN9DqwKu5Sxoddd1d7HZrbLo24xrl1/ 1EWUnI3aCzcfW+yykcX1qg2zrnCW/Txe0eonF7lW6c00W6dWdETsCVe9XJv2resXc/w1LB9/ jjdZFBL/NuKjR9oeQS8uL2czO+X0lhVaC+zCvb7yb7Dn37Jz89Ibk1b4JH7V3r6IuUene+eZ YqEveyb8+dRw2GGdpepd9bA/E70OTsoS2HiOLVn80P2dWRIro+1Mrqw+K3Q1/U3SqasBPpct 772aGHhSy0nSvXy5xw5Bi85sg+n6iqUf42+GqPBwrFziwC2j8cLgXMxyxuCHAn8StbsOPTus qzPp6fW8ogc3vl0y+CijEZJnfE92/1qDUmm+tR83KLEUZyQaajEXFScCAAPSXlJYAwAA X-CMS-MailID: 20230523122235eucas1p1398322259883bb53846e3445d7fd1cc6 X-Msg-Generator: CA X-RootMTR: 20230523122235eucas1p1398322259883bb53846e3445d7fd1cc6 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230523122235eucas1p1398322259883bb53846e3445d7fd1cc6 References: <20230523122220.1610825-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org We make register_sysctl_table static because the only function calling it is in fs/proc/proc_sysctl.c (__register_sysctl_base). We remove it from the sysctl.h header and modify the documentation in both the header and proc_sysctl.c files to mention "register_sysctl" instead of "register_sysctl_table". This plus the commits that remove register_sysctl_table from parport save 217 bytes: ./scripts/bloat-o-meter .bsysctl/vmlinux.old .bsysctl/vmlinux.new add/remove: 0/1 grow/shrink: 5/1 up/down: 458/-675 (-217) Function old new delta __register_sysctl_base 8 286 +278 parport_proc_register 268 379 +111 parport_device_proc_register 195 247 +52 kzalloc.constprop 598 608 +10 parport_default_proc_register 62 69 +7 register_sysctl_table 291 - -291 parport_sysctl_template 1288 904 -384 Total: Before=8603076, After=8602859, chg -0.00% Signed-off-by: Joel Granados Reviewed-by: Luis Chamberlain Signed-off-by: Luis Chamberlain --- fs/proc/proc_sysctl.c | 5 ++--- include/linux/sysctl.h | 8 +------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 8038833ff5b0..f8f19e000d76 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1582,7 +1582,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos, * array. A completely 0 filled entry terminates the table. * We are slowly deprecating this call so avoid its use. */ -struct ctl_table_header *register_sysctl_table(struct ctl_table *table) +static struct ctl_table_header *register_sysctl_table(struct ctl_table *table) { struct ctl_table *ctl_table_arg = table; int nr_subheaders = count_subheaders(table); @@ -1634,7 +1634,6 @@ struct ctl_table_header *register_sysctl_table(struct ctl_table *table) header = NULL; goto out; } -EXPORT_SYMBOL(register_sysctl_table); int __register_sysctl_base(struct ctl_table *base_table) { @@ -1700,7 +1699,7 @@ static void drop_sysctl_table(struct ctl_table_header *header) /** * unregister_sysctl_table - unregister a sysctl table hierarchy - * @header: the header returned from register_sysctl_table + * @header: the header returned from register_sysctl or __register_sysctl_table * * Unregisters the sysctl table and all children. proc entries may not * actually be removed until they are no longer used by anyone. diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 3d08277959af..218e56a26fb0 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -89,7 +89,7 @@ int proc_do_static_key(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos); /* - * Register a set of sysctl names by calling register_sysctl_table + * Register a set of sysctl names by calling register_sysctl * with an initialised array of struct ctl_table's. An entry with * NULL procname terminates the table. table->de will be * set up by the registration and need not be initialised in advance. @@ -222,7 +222,6 @@ struct ctl_table_header *__register_sysctl_table( struct ctl_table_set *set, const char *path, struct ctl_table *table); struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table); -struct ctl_table_header *register_sysctl_table(struct ctl_table * table); void unregister_sysctl_table(struct ctl_table_header * table); extern int sysctl_init_bases(void); @@ -257,11 +256,6 @@ static inline int __register_sysctl_base(struct ctl_table *base_table) #define register_sysctl_base(table) __register_sysctl_base(table) -static inline struct ctl_table_header *register_sysctl_table(struct ctl_table * table) -{ - return NULL; -} - static inline void register_sysctl_init(const char *path, struct ctl_table *table) { } From patchwork Tue May 23 12:22:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13252183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9FC8C7EE23 for ; Tue, 23 May 2023 12:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236872AbjEWMW7 (ORCPT ); Tue, 23 May 2023 08:22:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236833AbjEWMWw (ORCPT ); Tue, 23 May 2023 08:22:52 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D10E12B for ; Tue, 23 May 2023 05:22:38 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230523122237euoutp02a95e7539b03695218cd98a57efb37e3e~hxTK72Ev_1943019430euoutp02K for ; Tue, 23 May 2023 12:22:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230523122237euoutp02a95e7539b03695218cd98a57efb37e3e~hxTK72Ev_1943019430euoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684844557; bh=XgkbRo19UlgdrEJvMNy7N2uFh3oWcAT22mim1ypDjVs=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=a7ofdDb0csT5TBo0Gzshl+6CUFh30TL9pPvEOnlhE6xMgVkSE3kBMG2NACXoLQTH6 /TJ1zo7CRwfPnz3YwOl946TcDGJ11Yy01ufCe3cgHyHhpyeUsRg0XQa4rWWSHp3HkU 0eWOoLat1PCacffKWDc3wO4y3qMaHksUMvNgacr0= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230523122236eucas1p1836bfa829d041455149d950379d7752d~hxTKoiG5j1843818438eucas1p1y; Tue, 23 May 2023 12:22:36 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 7F.16.11320.C00BC646; Tue, 23 May 2023 13:22:36 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230523122236eucas1p17639bfdbfb30c9d751e0a8fc85fe2fd3~hxTKUg2Ds1843818438eucas1p1x; Tue, 23 May 2023 12:22:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230523122236eusmtrp2a28f795e5ac8c29f6d0a98a61d1d61ea~hxTKT6T3Q0682206822eusmtrp2Z; Tue, 23 May 2023 12:22:36 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-ad-646cb00c97bd Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1A.81.14344.C00BC646; Tue, 23 May 2023 13:22:36 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230523122236eusmtip28b71ff19fdedac7014bc085feb7047cf~hxTKHgzmo2661526615eusmtip2W; Tue, 23 May 2023 12:22:36 +0000 (GMT) Received: from localhost (106.210.248.82) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 May 2023 13:22:35 +0100 From: Joel Granados To: CC: Christian Brauner , Kees Cook , Joel Granados , , , Iurii Zaikin , Alexander Viro , Sudip Mukherjee Subject: [PATCH v4 7/8] sysctl: Refactor base paths registrations Date: Tue, 23 May 2023 14:22:19 +0200 Message-ID: <20230523122220.1610825-8-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230523122220.1610825-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.82] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNKsWRmVeSWpSXmKPExsWy7djPc7o8G3JSDGZOtbB4ffgTo8WZ7lyL PXtPslhc3jWHzeLGhKeMFgdOT2G2OP/3OKvFsp1+DhwesxsusnjsnHWX3WPBplKPTas62Tw+ b5Lz2PTkLVMAWxSXTUpqTmZZapG+XQJXxtHONWwFD9Uq1rd9Zmpg/CnbxcjJISFgIjHz1ge2 LkYuDiGBFYwSi3cfYwJJCAl8YZRovyYCkfjMKHFxzmcmmI5D+29AdSxnlJj65Rgr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slZGpkr6dTUpqTmZZ apG+XYJextHONWwFD9Uq1rd9Zmpg/CnbxcjJISFgInFo/w22LkYuDiGBpYwSWzfsY4dIyEhs /HKVFcIWlvhzrYsNxBYS+MgosXyxLETDFkaJ8zPvMIIk2AR0JM6/ucMMYosIiEucOL2ZEaSI WWA7k8SEv7uAujk4hAUcJbbOrgapYRFQldh1azkTiM0rYCvxvfc9G8QyeYm269PBZnIK2Ekc eraPFWKxrUTrq02sEPWCEidnPmEBsZmB6pu3zmaGsCUkDr54wQwxR0liddcfqJm1Ep//PmOc wCgyC0n7LCTts5C0L2BkXsUoklpanJueW2ykV5yYW1yal66XnJ+7iREYm9uO/dyyg3Hlq496 hxiZOBgPMUpwMCuJ8J4oz04R4k1JrKxKLcqPLyrNSS0+xGgK9OdEZinR5HxgcsgriTc0MzA1 NDGzNDC1NDNWEuf1LOhIFBJITyxJzU5NLUgtgulj4uCUamCyeXGmminUaX22y/Lnr632mIsv OKB7wbdFQkLS8NGa5793VF2eU3DwUN/Lj9v7hQV3ifzZJrp2Kf9V+y9Fs8LteScp2GjaTbAz +OnWYSmYFvVw/nb5Bvn78T9fX7iiEVnplPz5d9oy7sMafdXnUyd8bi6u/njjl83soosMH0zP qpv9z/6/VfDIviXZmgVrWKym5zyb+Of20lDDyY+2nZ4bWr3yzNrmvTssWtgV1HMLZ0vvbLXz n8Xr/ly7kX9Br+Bpo5NFcxUSCv+KclT6nXryMJS1R+6AQFqpXgd3R2rHy6OrZzy6tK/348zo rxuaJ22o9JhzVT878vttpawXBq9WmO1Y47X38bTOAP44J4dGJZbijERDLeai4kQA9yom8FYD AAA= X-CMS-MailID: 20230523122236eucas1p17639bfdbfb30c9d751e0a8fc85fe2fd3 X-Msg-Generator: CA X-RootMTR: 20230523122236eucas1p17639bfdbfb30c9d751e0a8fc85fe2fd3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230523122236eucas1p17639bfdbfb30c9d751e0a8fc85fe2fd3 References: <20230523122220.1610825-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is part of the general push to deprecate register_sysctl_paths and register_sysctl_table. The old way of doing this through register_sysctl_base and DECLARE_SYSCTL_BASE macro is replaced with a call to register_sysctl_init. The 5 base paths affected are: "kernel", "vm", "debug", "dev" and "fs". We remove the register_sysctl_base function and the DECLARE_SYSCTL_BASE macro since they are no longer needed. In order to quickly acertain that the paths did not actually change I executed `find /proc/sys/ | sha1sum` and made sure that the sha was the same before and after the commit. We end up saving 563 bytes with this change: ./scripts/bloat-o-meter vmlinux.0.base vmlinux.1.refactor-base-paths add/remove: 0/5 grow/shrink: 2/0 up/down: 77/-640 (-563) Function old new delta sysctl_init_bases 55 111 +56 init_fs_sysctls 12 33 +21 vm_base_table 128 - -128 kernel_base_table 128 - -128 fs_base_table 128 - -128 dev_base_table 128 - -128 debug_base_table 128 - -128 Total: Before=21258215, After=21257652, chg -0.00% Signed-off-by: Joel Granados [mcgrof: modified to use register_sysctl_init() over register_sysctl() and add bloat-o-meter stats] Signed-off-by: Luis Chamberlain Tested-by: Stephen Rothwell Acked-by: Christian Brauner --- fs/sysctls.c | 5 ++--- include/linux/sysctl.h | 23 ----------------------- kernel/sysctl.c | 30 +++++++++--------------------- 3 files changed, 11 insertions(+), 47 deletions(-) diff --git a/fs/sysctls.c b/fs/sysctls.c index c701273c9432..76a0aee8c229 100644 --- a/fs/sysctls.c +++ b/fs/sysctls.c @@ -29,11 +29,10 @@ static struct ctl_table fs_shared_sysctls[] = { { } }; -DECLARE_SYSCTL_BASE(fs, fs_shared_sysctls); - static int __init init_fs_sysctls(void) { - return register_sysctl_base(fs); + register_sysctl_init("fs", fs_shared_sysctls); + return 0; } early_initcall(init_fs_sysctls); diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 218e56a26fb0..653b66c762b1 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -197,20 +197,6 @@ struct ctl_path { #ifdef CONFIG_SYSCTL -#define DECLARE_SYSCTL_BASE(_name, _table) \ -static struct ctl_table _name##_base_table[] = { \ - { \ - .procname = #_name, \ - .mode = 0555, \ - .child = _table, \ - }, \ - { }, \ -} - -extern int __register_sysctl_base(struct ctl_table *base_table); - -#define register_sysctl_base(_name) __register_sysctl_base(_name##_base_table) - void proc_sys_poll_notify(struct ctl_table_poll *poll); extern void setup_sysctl_set(struct ctl_table_set *p, @@ -247,15 +233,6 @@ extern struct ctl_table sysctl_mount_point[]; #else /* CONFIG_SYSCTL */ -#define DECLARE_SYSCTL_BASE(_name, _table) - -static inline int __register_sysctl_base(struct ctl_table *base_table) -{ - return 0; -} - -#define register_sysctl_base(table) __register_sysctl_base(table) - static inline void register_sysctl_init(const char *path, struct ctl_table *table) { } diff --git a/kernel/sysctl.c b/kernel/sysctl.c index bfe53e835524..73fa9cf7ee11 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1782,11 +1782,6 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = sysctl_max_threads, }, - { - .procname = "usermodehelper", - .mode = 0555, - .child = usermodehelper_table, - }, { .procname = "overflowuid", .data = &overflowuid, @@ -1962,13 +1957,6 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dointvec, }, #endif -#ifdef CONFIG_KEYS - { - .procname = "keys", - .mode = 0555, - .child = key_sysctls, - }, -#endif #ifdef CONFIG_PERF_EVENTS /* * User-space scripts rely on the existence of this file @@ -2348,17 +2336,17 @@ static struct ctl_table dev_table[] = { { } }; -DECLARE_SYSCTL_BASE(kernel, kern_table); -DECLARE_SYSCTL_BASE(vm, vm_table); -DECLARE_SYSCTL_BASE(debug, debug_table); -DECLARE_SYSCTL_BASE(dev, dev_table); - int __init sysctl_init_bases(void) { - register_sysctl_base(kernel); - register_sysctl_base(vm); - register_sysctl_base(debug); - register_sysctl_base(dev); + register_sysctl_init("kernel", kern_table); + register_sysctl_init("kernel/usermodehelper", usermodehelper_table); +#ifdef CONFIG_KEYS + register_sysctl_init("kernel/keys", key_sysctls); +#endif + + register_sysctl_init("vm", vm_table); + register_sysctl_init("debug", debug_table); + register_sysctl_init("dev", dev_table); return 0; } From patchwork Tue May 23 12:22:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13252184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16ED1C7EE2E for ; Tue, 23 May 2023 12:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236890AbjEWMXA (ORCPT ); Tue, 23 May 2023 08:23:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236847AbjEWMWx (ORCPT ); Tue, 23 May 2023 08:22:53 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFA34184 for ; Tue, 23 May 2023 05:22:40 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230523122239euoutp0140b2c7b50acd73d4670593470bcd2179~hxTNLChrc1781217812euoutp01N for ; Tue, 23 May 2023 12:22:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230523122239euoutp0140b2c7b50acd73d4670593470bcd2179~hxTNLChrc1781217812euoutp01N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684844559; bh=aJ50gZPCUiYPfATuPiuF3FP7jhiW9EGQQWudnikqczE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=T6CjuxuOMbY7Jn1B+Hb6y1SeOkP3MP17eYWEVKaYAmV8+noDdpm7a5i5ArPDYbHIW 4Eh3w+0Pxc1y/d5D/zYdHry2bTJIqfg5kqOuLxN2acBT/umQg/gffYukdRPBwRAVoc 3AoLMFYfwG+1F3ymmcckDhGslVDruTOPcuGgJeyY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230523122239eucas1p190560f3aae58440d1d9c7c647b95a0af~hxTM5Jkkn2688426884eucas1p1P; Tue, 23 May 2023 12:22:39 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id A9.C8.42423.F00BC646; Tue, 23 May 2023 13:22:39 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230523122239eucas1p19c23501df7732d16422ab0489503c764~hxTMkyRy62670226702eucas1p1F; Tue, 23 May 2023 12:22:39 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230523122239eusmtrp24d64abac24d303b57ab36d8049c54933~hxTMkMy7R0682106821eusmtrp2h; Tue, 23 May 2023 12:22:39 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-10-646cb00f5040 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 60.CF.10549.E00BC646; Tue, 23 May 2023 13:22:38 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230523122238eusmtip284f979b57f69c7f863ed642bd93cefbf~hxTMYohQE1858618586eusmtip24; Tue, 23 May 2023 12:22:38 +0000 (GMT) Received: from localhost (106.210.248.82) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 May 2023 13:22:38 +0100 From: Joel Granados To: CC: Christian Brauner , Kees Cook , Joel Granados , , , Iurii Zaikin , Alexander Viro , Sudip Mukherjee Subject: [PATCH v4 8/8] sysctl: Remove register_sysctl_table Date: Tue, 23 May 2023 14:22:20 +0200 Message-ID: <20230523122220.1610825-9-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230523122220.1610825-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.82] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHKsWRmVeSWpSXmKPExsWy7djP87r8G3JSDNY9ErZ4ffgTo8WZ7lyL PXtPslhc3jWHzeLGhKeMFgdOT2G2OP/3OKvFsp1+DhwesxsusnjsnHWX3WPBplKPTas62Tw+ b5Lz2PTkLVMAWxSXTUpqTmZZapG+XQJXxsa2ZqaCpeYVRw49Ym9gfKnVxcjJISFgIvHy7RW2 LkYuDiGBFYwS+z4eZIFwvjBKTJ3+Ecr5zChx+tpmdpiWs+d/s0MkljNK7Pn/nAmu6tDrxawQ zhZGiek7usBa2AR0JM6/ucMMYosIiEucOL2ZEaSIWWAnk0R/5y02kISwgI3EhEu/mEBsFgFV iXcNf8AaeAVsJXZNm8YGsVteou36dEYQm1PATuLQs32sEDWCEidnPmEBsZmBapq3zmaGsCUk Dr54wQzRqySxuusP1JxaiVNbboGdLSHwg0Pi/vIGFoiEi8T5jr9MELawxKvjW6CelpH4v3M+ VMNkRon9/z6wQzirGSWWNX6F6rCWaLnyBKrDUWL/26lAcQ4gm0/ixltBiIv4JCZtm84MEeaV 6GgTmsCoMgvJD7OQ/DALyQ8LGJlXMYqnlhbnpqcWG+allusVJ+YWl+al6yXn525iBCah0/+O f9rBOPfVR71DjEwcjIcYJTiYlUR4T5RnpwjxpiRWVqUW5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JzFKiyfnABJFXEm9oZmBqaGJm aWBqaWasJM7rWdCRKCSQnliSmp2aWpBaBNPHxMEp1cCUO1dsvl/bf98LnD8bNwXoa/zY/nvG JMbXeou0V0t82da1PYmncMUXrSuqJw4x3Lr09z1bzw5XjZZz76eHVLsclhCIXXiicfZWnb/b 9z8/ZLF9xZStnX//6i3tfmFV0scg0bN8i2tQV0CWwrm7f/MPFgVvFvTu+bfaIDxf4tKn4lfH 7nLenq11/uBko7k7jK6ZPduzfWXF5YqYzIQfV/US9Y0eOdSX6Jvr6BZN02RXaKqc6/Nn0sv7 PJtfPO2eqPZ+lbX3nz7rfO9PQd9KBObEvZjssOXxJLP68GCx3VM0QubU33nz1eHnzhrp0vqp DLxqx6J2LywU0n/IOfO3z1ODc7cWnJpVp956XGvzluDF05RYijMSDbWYi4oTAXck6/RYAwAA X-CMS-MailID: 20230523122239eucas1p19c23501df7732d16422ab0489503c764 X-Msg-Generator: CA X-RootMTR: 20230523122239eucas1p19c23501df7732d16422ab0489503c764 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230523122239eucas1p19c23501df7732d16422ab0489503c764 References: <20230523122220.1610825-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is part of the general push to deprecate register_sysctl_paths and register_sysctl_table. After removing all the calling functions, we remove both the register_sysctl_table function and the documentation check that appeared in check-sysctl-docs awk script. We save 595 bytes with this change: ./scripts/bloat-o-meter vmlinux.1.refactor-base-paths vmlinux.2.remove-sysctl-table add/remove: 2/8 grow/shrink: 1/0 up/down: 1154/-1749 (-595) Function old new delta count_subheaders - 983 +983 unregister_sysctl_table 29 184 +155 __pfx_count_subheaders - 16 +16 __pfx_unregister_sysctl_table.part 16 - -16 __pfx_register_leaf_sysctl_tables.constprop 16 - -16 __pfx_count_subheaders.part 16 - -16 __pfx___register_sysctl_base 16 - -16 unregister_sysctl_table.part 136 - -136 __register_sysctl_base 478 - -478 register_leaf_sysctl_tables.constprop 524 - -524 count_subheaders.part 547 - -547 Total: Before=21257652, After=21257057, chg -0.00% Signed-off-by: Joel Granados [mcgrof: remove register_leaf_sysctl_tables and append_path too and add bloat-o-meter stats] Signed-off-by: Luis Chamberlain Acked-by: Christian Brauner --- fs/proc/proc_sysctl.c | 159 -------------------------------------- scripts/check-sysctl-docs | 10 --- 2 files changed, 169 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index f8f19e000d76..8873812d22f3 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1466,19 +1466,6 @@ void __init __register_sysctl_init(const char *path, struct ctl_table *table, kmemleak_not_leak(hdr); } -static char *append_path(const char *path, char *pos, const char *name) -{ - int namelen; - namelen = strlen(name); - if (((pos - path) + namelen + 2) >= PATH_MAX) - return NULL; - memcpy(pos, name, namelen); - pos[namelen] = '/'; - pos[namelen + 1] = '\0'; - pos += namelen + 1; - return pos; -} - static int count_subheaders(struct ctl_table *table) { int has_files = 0; @@ -1498,152 +1485,6 @@ static int count_subheaders(struct ctl_table *table) return nr_subheaders + has_files; } -static int register_leaf_sysctl_tables(const char *path, char *pos, - struct ctl_table_header ***subheader, struct ctl_table_set *set, - struct ctl_table *table) -{ - struct ctl_table *ctl_table_arg = NULL; - struct ctl_table *entry, *files; - int nr_files = 0; - int nr_dirs = 0; - int err = -ENOMEM; - - list_for_each_table_entry(entry, table) { - if (entry->child) - nr_dirs++; - else - nr_files++; - } - - files = table; - /* If there are mixed files and directories we need a new table */ - if (nr_dirs && nr_files) { - struct ctl_table *new; - files = kcalloc(nr_files + 1, sizeof(struct ctl_table), - GFP_KERNEL); - if (!files) - goto out; - - ctl_table_arg = files; - new = files; - - list_for_each_table_entry(entry, table) { - if (entry->child) - continue; - *new = *entry; - new++; - } - } - - /* Register everything except a directory full of subdirectories */ - if (nr_files || !nr_dirs) { - struct ctl_table_header *header; - header = __register_sysctl_table(set, path, files); - if (!header) { - kfree(ctl_table_arg); - goto out; - } - - /* Remember if we need to free the file table */ - header->ctl_table_arg = ctl_table_arg; - **subheader = header; - (*subheader)++; - } - - /* Recurse into the subdirectories. */ - list_for_each_table_entry(entry, table) { - char *child_pos; - - if (!entry->child) - continue; - - err = -ENAMETOOLONG; - child_pos = append_path(path, pos, entry->procname); - if (!child_pos) - goto out; - - err = register_leaf_sysctl_tables(path, child_pos, subheader, - set, entry->child); - pos[0] = '\0'; - if (err) - goto out; - } - err = 0; -out: - /* On failure our caller will unregister all registered subheaders */ - return err; -} - -/** - * register_sysctl_table - register a sysctl table hierarchy - * @table: the top-level table structure - * - * Register a sysctl table hierarchy. @table should be a filled in ctl_table - * array. A completely 0 filled entry terminates the table. - * We are slowly deprecating this call so avoid its use. - */ -static struct ctl_table_header *register_sysctl_table(struct ctl_table *table) -{ - struct ctl_table *ctl_table_arg = table; - int nr_subheaders = count_subheaders(table); - struct ctl_table_header *header = NULL, **subheaders, **subheader; - char *new_path, *pos; - - pos = new_path = kmalloc(PATH_MAX, GFP_KERNEL); - if (!new_path) - return NULL; - - pos[0] = '\0'; - while (table->procname && table->child && !table[1].procname) { - pos = append_path(new_path, pos, table->procname); - if (!pos) - goto out; - table = table->child; - } - if (nr_subheaders == 1) { - header = __register_sysctl_table(&sysctl_table_root.default_set, new_path, table); - if (header) - header->ctl_table_arg = ctl_table_arg; - } else { - header = kzalloc(sizeof(*header) + - sizeof(*subheaders)*nr_subheaders, GFP_KERNEL); - if (!header) - goto out; - - subheaders = (struct ctl_table_header **) (header + 1); - subheader = subheaders; - header->ctl_table_arg = ctl_table_arg; - - if (register_leaf_sysctl_tables(new_path, pos, &subheader, - &sysctl_table_root.default_set, table)) - goto err_register_leaves; - } - -out: - kfree(new_path); - return header; - -err_register_leaves: - while (subheader > subheaders) { - struct ctl_table_header *subh = *(--subheader); - struct ctl_table *table = subh->ctl_table_arg; - unregister_sysctl_table(subh); - kfree(table); - } - kfree(header); - header = NULL; - goto out; -} - -int __register_sysctl_base(struct ctl_table *base_table) -{ - struct ctl_table_header *hdr; - - hdr = register_sysctl_table(base_table); - kmemleak_not_leak(hdr); - return 0; -} - static void put_links(struct ctl_table_header *header) { struct ctl_table_set *root_set = &sysctl_table_root.default_set; diff --git a/scripts/check-sysctl-docs b/scripts/check-sysctl-docs index edc9a629d79e..4f163e0bf6a4 100755 --- a/scripts/check-sysctl-docs +++ b/scripts/check-sysctl-docs @@ -146,16 +146,6 @@ curtable && /\.procname[\t ]*=[\t ]*".+"/ { children[curtable][curentry] = child } -/register_sysctl_table\(.*\)/ { - match($0, /register_sysctl_table\(([^)]+)\)/, tables) - if (debug) print "Registering table " tables[1] - if (children[tables[1]][table]) { - for (entry in entries[children[tables[1]][table]]) { - printentry(entry) - } - } -} - END { for (entry in documented) { if (!seen[entry]) {