From: sashiko-bot@kernel.org
To: "Jiri Pirko" <jiri@resnulli.us>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH RFC 12/20] ctlv: Add device and operation dispatch
Date: Thu, 15 Oct 2026 15:28:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-173071@kernel.org> (raw)
In-Reply-To: <20261015145053.3664509-13-jiri@resnulli.us>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] ctlv: mixing goto-based error handling with scope-based cleanup (__free)
--
commit d40367eef6344eb381abe711a6b81ec26de22d13
Author: Jiri Pirko <jiri@nvidia.com>
ctlv: Add device and operation dispatch
Register CTLV devices, resolve family chains and dispatch operations
through validated messages. Wire CONFIG_CTLV and the generated root family
after all module objects are present.
> diff --git a/drivers/ctlv/core.c b/drivers/ctlv/core.c
> new file mode 100644
> index 0000000000000..aeab29fe2fdd4
> --- /dev/null
> +++ b/drivers/ctlv/core.c
[ ... ]
> +static int ctlv_op_exec(struct ctlv_file *cfile, struct file *filp, struct ctlv_op_exec *exec,
> + void **reply, u32 *reply_len)
> +{
> + struct ctlv_device *ctlvdev = cfile->ctlvdev;
> + const struct ctlv_op_entry *op;
> + struct ctlv_op_ctx ctx = {};
> + u32 capacity;
> + int ret;
[ ... ]
> + void *snapshot __free(kvfree) = NULL;
> + void *out __free(kvfree) = NULL;
> +
> + if (exec->request_len < sizeof(struct ctlv_attr) ||
> + exec->request_len > CTLV_MAX_INLINE_MESSAGE_LEN)
> + return -EINVAL;
> + /* Everything after this reads the snapshot, never userspace. */
> + snapshot = kvmalloc(exec->request_len, GFP_KERNEL_ACCOUNT);
> + if (!snapshot)
> + return -ENOMEM;
> + if (copy_from_user(snapshot, u64_to_user_ptr(exec->request), exec->request_len))
> + return -EFAULT;
> + /* Before any hook, so that no family code sees an unchecked attr. */
> + ret = ctlv_request_validate(&ctx, exec, snapshot);
> + if (ret)
> + goto out_error_info;
[ ... ]
> + /* Where the caller carries on from, zero for anything but a query. */
> + exec->generation = ctx.frag.reported;
> + exec->cursor = ctx.frag.next_cursor;
> + *reply_len = ctx.output.root ? ctx.output.root->len : 0;
> + *reply = no_free_ptr(out);
> + ret = 0;
> + goto out_request;
> +
> +out_error_info:
> + ctlv_error_info(&ctx, exec->reply_len, reply, reply_len);
> +out_request:
> + ctlv_message_index_free(&ctx.request);
> + return ret;
> +}
[Severity: Low]
Does this mix scope-based cleanup (__free) with goto-based error handling?
The cleanup guidelines (include/linux/cleanup.h) state that functions
should either convert all resources to scope-based cleanup or convert none
of them, but never mix the two in the same function.
[ ... ]
> +struct ctlv_device *ctlv_create(struct device *parent_dev, const struct ctlv_family *family,
> + const void *init_info)
> +{
> + struct ctlv_device *ctlvdev;
> + int devnum, ret;
[ ... ]
> + ctlv_event_contexts_start(ctlvdev);
> + ret = ctlv_family_privs_post_init(ctlvdev);
> + if (ret)
> + goto err_fini;
> + scoped_guard(rwsem_write, &ctlvdev->registration_lock) {
> + ret = ctlv_device_add(ctlvdev);
> + if (!ret)
> + ctlvdev->registered = true;
> + }
> + if (ret)
> + goto err_fini;
> + return ctlvdev;
> +
> +err_fini:
> + ctlv_device_fini(ctlvdev);
> +err_put:
> + put_device(&ctlvdev->dev);
> + return ERR_PTR(ret);
> +err_free:
> + bitmap_free(ctlvdev->disabled);
> + ctlv_family_privs_free(ctlvdev);
> + kfree(ctlvdev->ops);
> + kfree(ctlvdev);
> + return ERR_PTR(ret);
> +}
[Severity: Low]
Does this mix scoped_guard with goto-based error handling?
The kernel guidelines expect functions to avoid mixing goto error labels and
scope-based cleanup macros like scoped_guard.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015145053.3664509-1-jiri@resnulli.us?part=12
next prev parent reply other threads:[~2026-10-15 15:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:50 [PATCH RFC 00/20] attestation: Add a common subsystem and TDX support Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 01/20] ctlv: Add the schema language and generator Jiri Pirko
2026-10-15 14:58 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 02/20] ctlv: Add the UAPI wire format and family API Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 03/20] ctlv: Add the root family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 04/20] Documentation: ctlv: Add userspace ABI Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 05/20] ctlv: Prepare message input handling Jiri Pirko
2026-10-15 15:06 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 06/20] ctlv: Prepare blob descriptor validation Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 07/20] ctlv: Prepare schema validation Jiri Pirko
2026-10-15 15:14 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 08/20] ctlv: Prepare message output handling Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 09/20] ctlv: Prepare VA blob handling Jiri Pirko
2026-10-15 15:14 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 10/20] ctlv: Prepare event queue support Jiri Pirko
2026-10-15 15:22 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 11/20] ctlv: Prepare runtime introspection Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 12/20] ctlv: Add device and operation dispatch Jiri Pirko
2026-10-15 15:28 ` sashiko-bot [this message]
2026-10-15 14:50 ` [PATCH RFC 13/20] Documentation: ctlv: Describe how to write a family Jiri Pirko
2026-10-15 15:20 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 14/20] attestation: Add the base family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 15/20] attestation: Prepare provider and instance core Jiri Pirko
2026-10-15 15:30 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 16/20] attestation: Prepare measurement register journal Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 17/20] attestation: Add CTLV operation handling Jiri Pirko
2026-10-15 15:33 ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 18/20] tdx-guest: Expose the native attestation service API Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 19/20] attestation: Add the TDX family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 20/20] attestation: Add the TDX family implementation Jiri Pirko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-173071@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jiri@resnulli.us \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox