From: Dan Carpenter <dan.carpenter@linaro.org>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: "Matthew Brost" <matthew.brost@intel.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Himal Prasad Ghimiray" <himal.prasad.ghimiray@intel.com>,
intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH next] drm/xe: Fix uninitialized variable in xe_vm_bind_ioctl()
Date: Mon, 10 Mar 2025 21:22:50 +0300 [thread overview]
Message-ID: <95a4da90-dfa0-4033-aba5-276b3d9a1824@stanley.mountain> (raw)
In-Reply-To: <Z88ZzoFA5KpQTLmH@intel.com>
On Mon, Mar 10, 2025 at 12:56:46PM -0400, Rodrigo Vivi wrote:
> On Mon, Mar 10, 2025 at 01:48:00PM +0300, Dan Carpenter wrote:
> > The error handling assumes that vm_bind_ioctl_check_args() will
> > initialize "bind_ops" but there are a couple early returns where that's
> > not true. Initialize "bind_ops" to NULL from the start.
>
> It is not a couple, but only the one goto put_vm where this bind_ops
> gets actually initialized, or not...
>
I'm on linux-next. I'm not seeing the goto put_vm... I think we're
looking at different code.
3063 static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,
3064 struct drm_xe_vm_bind *args,
3065 struct drm_xe_vm_bind_op **bind_ops)
3066 {
3067 int err;
3068 int i;
3069
3070 if (XE_IOCTL_DBG(xe, args->pad || args->pad2) ||
3071 XE_IOCTL_DBG(xe, args->reserved[0] || args->reserved[1]))
3072 return -EINVAL;
One.
3073
3074 if (XE_IOCTL_DBG(xe, args->extensions))
3075 return -EINVAL;
Two.
3076
3077 if (args->num_binds > 1) {
3078 u64 __user *bind_user =
3079 u64_to_user_ptr(args->vector_of_binds);
3080
3081 *bind_ops = kvmalloc_array(args->num_binds,
Initialized.
3082 sizeof(struct drm_xe_vm_bind_op),
3083 GFP_KERNEL | __GFP_ACCOUNT |
3084 __GFP_RETRY_MAYFAIL | __GFP_NOWARN);
3085 if (!*bind_ops)
3086 return args->num_binds > 1 ? -ENOBUFS : -ENOMEM;
3087
3088 err = __copy_from_user(*bind_ops, bind_user,
3089 sizeof(struct drm_xe_vm_bind_op) *
3090 args->num_binds);
3091 if (XE_IOCTL_DBG(xe, err)) {
3092 err = -EFAULT;
3093 goto free_bind_ops;
3094 }
3095 } else {
3096 *bind_ops = &args->bind;
3097 }
> but perhaps the order in the exit is wrong and we should move the
> kvfree(bind_ops) upper to the end of put_exec_queue?
>
> Matt, thoughts on the order here?
>
> Cc: Matthew Brost <matthew.brost@intel.com>
I feel like ideally vm_bind_ioctl_check_args() would clean up after
itself on failure and, yes, it should be in reverse order from how
it was allocated.
regards,
dan carpenter
next prev parent reply other threads:[~2025-03-10 18:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 10:48 Dan Carpenter
2025-03-10 16:56 ` Rodrigo Vivi
2025-03-10 18:22 ` Dan Carpenter [this message]
2025-03-11 5:04 ` Matthew Brost
2025-03-11 5:12 ` Matthew Brost
2025-03-12 6:17 ` Matthew Brost
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=95a4da90-dfa0-4033-aba5-276b3d9a1824@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®