Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp757163lqg; Sat, 2 Mar 2024 00:08:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVHKrwkOqSsD0ZJZWtnkpwkUtJJhidAgD7lbjMBZpu8tdOHXlIpkIPAydxp/mkoUMvgy+Q+8eoQA3/ej7NEoAGplGJRCOzrOMbOAgm+Ug== X-Google-Smtp-Source: AGHT+IGfuaqtxJpnFUfA3lVf+eQZKMpyt69DA+MrhzCHbtRT7VgkKm9T+k4grNZ25iUXA8efDTBd X-Received: by 2002:a05:6808:180a:b0:3c1:e108:d82e with SMTP id bh10-20020a056808180a00b003c1e108d82emr982977oib.27.1709366907593; Sat, 02 Mar 2024 00:08:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709366907; cv=pass; d=google.com; s=arc-20160816; b=VNsid9g5aFs7KXHsCvFeygzrXcSw6zM64+zfUewbDu298R3zTDeisERBAD8g/8GCW0 QuvChh69pbgYfuqkctLImM13Y+JGhOkwBnlYHMwJiQFQuOsMjjo9F+ny1s7esCN3u+A8 NS9ZoMpHbsDtC2X6F1wcx60o2Z/stUAfoxXOLYihlZ2O6tQEGjtaLjWwWWcezM71pFFc jl+X5OrrYCANwF9t+jthv3SKa27JJGN359GoO+Q2mn4lG4lRhxFzb+bAoqFkpW1R+yp0 rQjI+ssJJ4auhfXylFZWoMmNmTlxFgwi9b2DwFsX8smobDHxge+8x+5817I2J83Pjb/S +oWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vlcjU9vdfaaOYlXnDsun+A18a7hgsK4VcGVSuDX7glU=; fh=LvMadvKUweSoOk4yGwZjfWTCt7260Xo1sqkQYuWIFWk=; b=b3wArYfJ4t0LcC4ay8gsorixz6qVvUE3eTntd5eADCxN7F7Ep0wCZo7OxqFLoQ+WcB buphESJjB7S/RDJlOo/eqLQnCQwmXwzBrGYTEnmx/5pYHDyeoU4M4sD3NxjGWqzv9q6g VxjdqCtC+Hc7PhMDTr+gApXukzTPf+j6OBqD3x50JTkwgmI7LrS2NI0YLANnHAb1rOWt pP6HSb8To1qfjJyMSM0tLU1t9VcLlDUpc7Coru0jkqZeB4w0BQIhDn7nIMO+aRWsMd/h 4FzxuLpduRbdUzAtB0XOtd7FoqoNnvZP3uBuolc6mhz6nzzZSC0SlRVGNujIpnLklN93 JCyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mV4Z1F9D; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-89364-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89364-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p11-20020a63e64b000000b005e271b946a6si5082700pgj.765.2024.03.02.00.08.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 00:08:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89364-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mV4Z1F9D; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-89364-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89364-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E12F9B22B2E for ; Sat, 2 Mar 2024 08:05:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A14311428F; Sat, 2 Mar 2024 08:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mV4Z1F9D" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB6851426A for ; Sat, 2 Mar 2024 08:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709366693; cv=none; b=uYCiDu1lAWv3Y3ys5eVfc/pZo9BYDQmFZUa3oB+xfJrm8YfM0+ZrRrQo+n6VVz8LX7gqE8F2cr0w3dXiam2NePPn4Sj+CnWfmJ6W6ogTrYBKhV03cib20LNKE6d1ZBtoiu0vMeA4Q7I4UVTzp7bUxcT7iK63b0/qEltJ2VGFiI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709366693; c=relaxed/simple; bh=H/YJZEDdXlIWQCIEC0J6BtWB1k5oNc1HPmB0ABvqoJU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XU2NSS1GNgbM30pVHLgHzA4x1Lh85EAxzm4K1+2i3Du5aJZOjUxipAWAByWMq4wmjaJl9mPLPK4wrnVMdrbQpl5BZNiKjyPCx3Xv0is3ri40wPfZEPh/NPa/zRTAjTH1Zw5Uu5hGQi5sQhph5hw+uZoXovNA2eVrcE9vdBGhppk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mV4Z1F9D; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28717C433C7; Sat, 2 Mar 2024 08:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709366693; bh=H/YJZEDdXlIWQCIEC0J6BtWB1k5oNc1HPmB0ABvqoJU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mV4Z1F9D4w8meE9LccOD7Cm77nWZ24nQRBkgVqvyFDqVxPV44YqymRMj/aWQs8BRP 65aB7Vwj2zKFhZNPQN3gG87Z15gh3pgz60HdHr9a0blwqvT+zu+kqWksdFVi5uKaii Of1eIhGtIdqixjuFmR2znd7oBUwl9KBSf7yJ6Wf/0f/fOtH4M1GVHO8sG3z4X2o81R uYRAmoj7NY/14W3X2iWBwCkHzJ5Alc5mCqLKdwrEZTuGIzIFptSuOSXiVFC9TLUeNO sU7yNfLOz4Y9v38Ll7/lPcoZdoz3XDxt5uGjbfv5by52P5VYjyPTRpJv9YEESK/HEI GYVFvy7dgwAEg== Date: Sat, 2 Mar 2024 00:04:52 -0800 From: Saeed Mahameed To: Vegard Nossum Cc: Arnd Bergmann , Greg Kroah-Hartman , Leon Romanovsky , Jason Gunthorpe , Jiri Pirko , Leonid Bloch , Itay Avraham , Jakub Kicinski , Saeed Mahameed , David Ahern , Aron Silverton , Christoph Hellwig , andrew.gospodarek@broadcom.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH V4 2/5] misc: mlx5ctl: Add mlx5ctl misc driver Message-ID: References: <20240207072435.14182-1-saeed@kernel.org> <20240207072435.14182-3-saeed@kernel.org> <14aca96c-7525-486c-8f7c-accaddd41456@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <14aca96c-7525-486c-8f7c-accaddd41456@oracle.com> On 29 Feb 12:44, Vegard Nossum wrote: > >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? Good catch !, thanks I will reorder.