lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <14aca96c-7525-486c-8f7c-accaddd41456@oracle.com>
Date: Thu, 29 Feb 2024 12:44:03 +0100
From: Vegard Nossum <vegard.nossum@...cle.com>
To: Saeed Mahameed <saeed@...nel.org>, Arnd Bergmann <arnd@...db.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Leon Romanovsky <leonro@...dia.com>, Jason Gunthorpe <jgg@...dia.com>,
        Jiri Pirko <jiri@...dia.com>, Leonid Bloch <lbloch@...dia.com>,
        Itay Avraham <itayavr@...dia.com>, Jakub Kicinski <kuba@...nel.org>,
        Saeed Mahameed <saeedm@...dia.com>, David Ahern <dsahern@...nel.org>,
        Aron Silverton <aron.silverton@...cle.com>,
        Christoph Hellwig <hch@...radead.org>, andrew.gospodarek@...adcom.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH V4 2/5] misc: mlx5ctl: Add mlx5ctl misc driver


On 07/02/2024 08:24, Saeed Mahameed wrote:
> +static int mlx5ctl_open(struct inode *inode, struct file *file)
> +{
> +	struct mlx5_core_dev *mdev;
> +	struct mlx5ctl_dev *mcdev;
> +	struct mlx5ctl_fd *mfd;
> +	int err = 0;
> +
> +	mcdev = container_of(file->private_data, struct mlx5ctl_dev, miscdev);
> +	mcdev_get(mcdev);
> +	down_read(&mcdev->rw_lock);
> +	mdev = mcdev->mdev;
> +	if (!mdev) {
> +		err = -ENODEV;
> +		goto unlock;
> +	}
> +
> +	mfd = kzalloc(sizeof(*mfd), GFP_KERNEL_ACCOUNT);
> +	if (!mfd)
> +		return -ENOMEM;

goto unlock?

Or why not reorder so you always allocate this before doing anything else?

> +
> +	mfd->mcdev = mcdev;
> +	err = mlx5ctl_open_mfd(mfd);
> +	if (err)
> +		goto unlock;
> +
> +	spin_lock(&mcdev->fd_list_lock);
> +	list_add_tail(&mfd->list, &mcdev->fd_list);
> +	spin_unlock(&mcdev->fd_list_lock);
> +
> +	file->private_data = mfd;
> +
> +unlock:
> +	up_read(&mcdev->rw_lock);
> +	if (err) {
> +		mcdev_put(mcdev);
> +		kfree(mfd);
> +	}
> +	return err;
> +}


Vegard

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ