Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2521524rwd; Mon, 15 May 2023 12:53:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7X/rIHWk7tB2PEJfLxTdQdW7/+9+px/DcsVerrlWPfiSd/j8YLuu/JfMP+7Om2KJXm6OEt X-Received: by 2002:a05:6a20:e68e:b0:103:8f9a:8743 with SMTP id mz14-20020a056a20e68e00b001038f9a8743mr19635560pzb.43.1684180424153; Mon, 15 May 2023 12:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684180424; cv=none; d=google.com; s=arc-20160816; b=0fcdfTJW2WqvKqKI/14iHakVkjELotdUyBioJoUUge8qB0SUrG9gkHUjTLRunDRTGH ZW745HlkOwV94firBTPeJAnaBTmy3cYbs+uZxQVjP9zbxIl3upFlRgL2bEvyWOnc+PSU 8ZCEGx6p1Xv9nfrGOdRE79vEE7AxvJ5v9l8gwHtmwipscM5yB+UBqSFUdL4JCFxg5qN/ RABzhG3F/fFKt89aiPJDECaLLCa+yKaAN+3AnbY8iP2Kf28ulInD3sqNXZkEQ49OXUn1 u1B329wq2yFZqwoCGNzNsMBeP7khP77UHP9d2CsHt8y3HoU02SKE3R0A6725168aOlLt UMcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=MZizuEmpa6HEDzwMlyOy37v0ca5o+HLnRNi8YYY2vus=; b=eQs+7+gVFaCLkU5ny86eS50PbyKCp5o4QexhWekAwXQr7rMeGGv62/D7juNNwANB3r c4iFCuh5hKbpctr6cMAeISkgfqXFXuTN+pWApIHTqI7CxxkUu28Zu1NVJWM/TX793a2h AkvCFJ3pVhmgo+tFPUd7c9LPozN7ghkh3W5/6JZ7CsdMWLWdoB+xL8zLGiF6+Qz4nVgg gFAGySOE4NZhBfz/vypwIAkKb8qtwbDpNXPO7Oc4dwtJaV/C9Ja/Rmt6XMcLy15057Ld w63xnK3KwkdwY5Psw0ftGqOeikDjuKuKAMKW9dtCK1MBG7F/dcr2uoqzuMnATIQoW5ZU f7Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="B6PJ1M/2"; 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 i30-20020a63585e000000b0052856cec94asi16082180pgm.884.2023.05.15.12.53.19; Mon, 15 May 2023 12:53:44 -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="B6PJ1M/2"; 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 S244730AbjEOT1K (ORCPT + 99 others); Mon, 15 May 2023 15:27:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244816AbjEOT0h (ORCPT ); Mon, 15 May 2023 15:26:37 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44749100DC; Mon, 15 May 2023 12:26:34 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230515192631euoutp0244bec1aaec114b56b24caea5accec525~fZ7ACyghJ2118921189euoutp02F; Mon, 15 May 2023 19:26:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230515192631euoutp0244bec1aaec114b56b24caea5accec525~fZ7ACyghJ2118921189euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684178791; bh=MZizuEmpa6HEDzwMlyOy37v0ca5o+HLnRNi8YYY2vus=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=B6PJ1M/2S2P3sPzF8dYDoySsvbQp5QvWVce1Zqfo56VmijiNUEKi/3IwpvxyYVRyB vBAZKzePyJysVwVFchZSNTauTkoJvzB2DgPbNkr7r1ByM7/1CjOscr7P+z3UXOFe4w yG2QN4TkXs++M2iZCGV3e2kWFsJXhHDAvW+sUChU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230515192630eucas1p10027f3d06c4c536807790ef34e9f738a~fZ6-pRY3I0033900339eucas1p1h; Mon, 15 May 2023 19:26:30 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 84.33.42423.66782646; Mon, 15 May 2023 20:26:30 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230515192630eucas1p2c9bf0ffa8ddc2d0bcf9a9818c6ecd6a8~fZ6-V46-G0354903549eucas1p2U; Mon, 15 May 2023 19:26:30 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230515192630eusmtrp233b104dc992b6c4bd29ad2018d157335~fZ6-VYhXt0400204002eusmtrp2m; Mon, 15 May 2023 19:26:30 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-83-646287660dda Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id DE.67.10549.66782646; Mon, 15 May 2023 20:26:30 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230515192630eusmtip2b07e828d712e36c1ab24dce8b3e6534e~fZ6-HYOrf0896408964eusmtip2F; Mon, 15 May 2023 19:26:30 +0000 (GMT) Received: from localhost (106.210.248.56) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 15 May 2023 20:26:29 +0100 Date: Mon, 15 May 2023 21:10:19 +0200 From: Joel Granados To: CC: Sudip Mukherjee , Iurii Zaikin , Kees Cook , , Subject: Re: [PATCH 3/6] parport: Remove register_sysctl_table from parport_device_proc_register Message-ID: <20230515191019.cggga6c7yhnjzj4a@localhost> MIME-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="wytu3hi3jl3xaskq" Content-Disposition: inline In-Reply-To: <20230515071446.2277292-4-j.granados@samsung.com> X-Originating-IP: [106.210.248.56] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7djPc7pp7UkpBhfX6Vmc6c612LP3JIvF 5V1z2CxuTHjKaHHg9BRmi2U7/RzYPGY3XGTx2DnrLrvHgk2lHptWdbJ5fN4kF8AaxWWTkpqT WZZapG+XwJWx+8g+9oIXKhUT9yxnb2DcJdfFyMkhIWAiMelfLzOILSSwglFiz+WYLkYuIPsL o8St5xeYIJzPjBKv91xk7WLkAOu49lkVIr6cUeLi54MIRWen3WGHcLYwSvzt2c0CMpdFQFXi 78x+RhCbTUBH4vybO2D7RATEJU6c3swI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ti5OCQEDCRuPZZtYuRi0NIYCmjxMTLi1m6GDmB4jISG79cZYWwhSX+XOtigyj6 yCjRs20dO4SzhVHi44mrzCBVLAKqEn9n9jOC2GwCOhLn39wBi4sIiEucOL2ZEaSBWWA3o8S3 A5PBxgoLJEnMXL+NCcTmFTCXWPtkMjuILSRQKHHn+Sw2iLigxMmZT8BOYhYok7jTCBLnALKl JZb/4wAJcwrYSVyaOJ0N4lIlifaJD6CurpX4/PcZ4wRG4VlIJs1CMmkWwiSIsJbEjX8vmTCE tSWWLXzNDGHbSqxb955lASP7KkaR1NLi3PTcYkO94sTc4tK8dL3k/NxNjMAI3nbs5+YdjPNe fdQ7xMjEwXiIUQWo89GG1RcYpVjy8vNSlUR422fGpwjxpiRWVqUW5ccXleakFh9iNAWG4kRm KdHkfGBqySuJNzQzMDU0MbM0MLU0M1YS5/Us6EgUEkhPLEnNTk0tSC2C6WPi4JRqYIqwdtuV 299YsOO+s+a6G1tfrlr1hlFnesm6R5FfZ5i+6Jqw8WZFwzvPuqDbV+p2XQqTXKv0fcK8pvqS dwXKv/aYG7xQk3+TZ7qv4uwn5S028kVf/5xO+HvrxhGBo66HG+YdNywpcHqvns6UynPZ5spi x7Oa7uF3Dys8Oxtq0H4sdfGK5c9/9b7OfFBg/z/7deuq+M4lrt8CvQ8InVnPc2GvrNn/kLk8 7/h2KvUULDgW/c9HUEGh83nt9g8HE9cHpE9hmrqD4aAvO0PoPh6Hos/1a/hiDdoLbI+oxxkb 6Dbv2l3Us/anxmrHS1P1/kv7MHfd55h5QFUzZMP1gol8U/44/v9emtVzQe+r5fMX6oeUWIoz Eg21mIuKEwHNb5cidQMAAA== X-CMS-MailID: 20230515192630eucas1p2c9bf0ffa8ddc2d0bcf9a9818c6ecd6a8 X-Msg-Generator: CA X-RootMTR: 20230515192630eucas1p2c9bf0ffa8ddc2d0bcf9a9818c6ecd6a8 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230515192630eucas1p2c9bf0ffa8ddc2d0bcf9a9818c6ecd6a8 References: <20230515071446.2277292-1-j.granados@samsung.com> <20230515071446.2277292-4-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 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 autolearn=ham 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 --wytu3hi3jl3xaskq Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 15, 2023 at 09:14:43AM +0200, Joel Granados wrote: > 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. >=20 > Signed-off-by: Joel Granados > --- > drivers/parport/procfs.c | 57 +++++++++++++++++++++++----------------- > 1 file changed, 33 insertions(+), 24 deletions(-) >=20 > diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c > index 53ae5cb98190..902547eb045c 100644 > --- a/drivers/parport/procfs.c > +++ b/drivers/parport/procfs.c > @@ -384,6 +384,7 @@ parport_device_sysctl_template =3D { > .extra1 =3D (void*) &parport_min_timeslice_value, > .extra2 =3D (void*) &parport_max_timeslice_value > }, > + {} > }, > { > { > @@ -394,22 +395,6 @@ parport_device_sysctl_template =3D { > .child =3D NULL > }, > {} > - }, > - { > - PARPORT_DEVICES_ROOT_DIR, > - {} > - }, > - { > - PARPORT_PORT_DIR(NULL), > - {} > - }, > - { > - PARPORT_PARPORT_DIR(NULL), > - {} > - }, > - { > - PARPORT_DEV_DIR(NULL), > - {} > } > }; > =20 > @@ -547,30 +532,54 @@ int parport_proc_unregister(struct parport *port) > =20 > int parport_device_proc_register(struct pardevice *device) > { > + int err =3D 0; > struct parport_device_sysctl_table *t; > struct parport * port =3D device->port; > + size_t port_name_len, device_name_len, tmp_dir_path_len; > + char *tmp_dir_path; > =09 > t =3D kmemdup(&parport_device_sysctl_template, sizeof(*t), GFP_KERNEL); > if (t =3D=3D NULL) > return -ENOMEM; > =20 > - t->dev_dir[0].child =3D t->parport_dir; > - t->parport_dir[0].child =3D t->port_dir; > - t->port_dir[0].procname =3D port->name; > - t->port_dir[0].child =3D t->devices_root_dir; > - t->devices_root_dir[0].child =3D t->device_dir; > + port_name_len =3D strnlen(port->name, PARPORT_NAME_MAX_LEN); > + device_name_len =3D strnlen(device->name, PATH_MAX); > + > + /* Allocate a buffer for two paths: dev/parport/PORT/devices/DEVICE. */ > + tmp_dir_path_len =3D PARPORT_BASE_DEVICES_PATH_SIZE + port_name_len + d= evice_name_len; > + tmp_dir_path =3D kmalloc(tmp_dir_path_len, GFP_KERNEL); > + if (!tmp_dir_path) { > + err =3D -ENOMEM; > + goto exit_free_t; > + } > + > + if (tmp_dir_path_len > + <=3D snprintf(tmp_dir_path, tmp_dir_path_len, "dev/parport/%s/devic= es/%s", > + port->name, device->name)) { > + err =3D -ENOENT; > + goto exit_free_path; > + } > =20 > - t->device_dir[0].procname =3D device->name; > - t->device_dir[0].child =3D t->vars; > t->vars[0].data =3D &device->timeslice; > =20 > - t->sysctl_header =3D register_sysctl_table(t->dev_dir); > + t->sysctl_header =3D register_sysctl(tmp_dir_path, t->vars); > if (t->sysctl_header =3D=3D NULL) { > kfree(t); > t =3D NULL; In the paprport_proc_register there is the same logic where we do not return error code on error. Additionally, noone checks the return values of parport_proc_register nor parport_device_proc_register. Should we just change these to void and be done with it? Or is it better to change parport/share.c to take care of the error codes? I realized this after some comments from 0-day. Best > } > device->sysctl_table =3D t; > + > + kfree(tmp_dir_path); > return 0; > + > +exit_free_path: > + kfree(tmp_dir_path); > + > +exit_free_t: > + kfree(t); > + t =3D NULL; > + > + return err; > } > =20 > int parport_device_proc_unregister(struct pardevice *device) > --=20 > 2.30.2 >=20 --=20 Joel Granados --wytu3hi3jl3xaskq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmRig4wACgkQupfNUreW QU+5qAv/XUSUpZ7GDIyi+UcJXFhuAnY7M/KsHwYQTxZVoFVqp/KB2Xi26TYWbXSZ MHGPBo0gfFm3wxXNqUoY8hGBRHOUJ33o6yzNYj4rs8WP1ncaySX7fk+9pAD1s+SN QqETROf1xU0wiFZHOM75/aazrMFFjPLl7iiT0Jz/g7qE8MsnBqYB/2cp848jMgqw 8P7c30PP3YldPeWSgBISG9fQpfRkYrJzdnMg9NHpFFdLS8cHRXS8hhmXnoCozt6L NkBj+jZ8B+v49XFrbu0Sdkdn4y4OFxJ3ca6OUlz1nM+cvzX5Z5xuPBiG4s5C92u9 ZFdLd7gkrz4kVmiSZ4bPlwHUBElNTvGAHzuXmDcUvVJm9DnbUUYq7eu6sHqFlBtn mY2o6Nilem4m+dvdU+ukg+dzEGEzc0GS5FAomhWz1snpTKGe7cavN2ItZvfUjaq4 z2pw10ojjpeyVAjUGvb/UjPmLdG5LI8tIM1aUuF9Xvip1VxsfZ2y8ovEHwnXxe2d dtBBkUUz =1gYL -----END PGP SIGNATURE----- --wytu3hi3jl3xaskq--