Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2917296rwb; Thu, 29 Sep 2022 17:29:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5n5bGMlw5D2PXRQyLd4MwK1F4lEbCVLphly6/WQ/QNo4vQ//EgVNevjhs4nPhGRQtc1Lpz X-Received: by 2002:a17:906:5d04:b0:722:f46c:b891 with SMTP id g4-20020a1709065d0400b00722f46cb891mr4721598ejt.4.1664497778933; Thu, 29 Sep 2022 17:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664497778; cv=none; d=google.com; s=arc-20160816; b=w4t/HNjToocTRNHrrKmkp8AsDOTU/bKTjmglgDuyT+hEIppSR0BBZ7ati1PW2PodFV d1ppJw6cuLmGB9aIj/WaByPJc7/v7oRwcgRpynNSa3OsfOhgUsjU8ElkR6fwN/v3WpXD Xb67O/6HqMFKvjm+Xg2gD07QuHQ9ZdqU2aSaz8ck4sMuAYxYTY8FJXeE1sVTSK9MIA9P cyHNBo8g2E7+6XNYr8cz1+ogqBoYGe6wmts5BJPjYgyfbPX287x4Syj+JX/D0DzTBoqY v77sQt5Df0gqBxS4+MeDPtn3gUSrhdhFljyJsw4L6wqU3gF+Xy6XSahgcvsVrMfLsYyr x1Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4Bta6uh+/S8ur+ikl4X0ejv9pRv/76aMXaS+owY3HiU=; b=xo1nAuw3+pwWsfdTHzJyl4iA8/W8hojVbq8UnfkwI4N5HQ/tvjLDLoh/YE32liz/p6 GWrDFWa0K0tpINo+FHm/NLIFd0SE15s3W6OJ02DlDCc0ZuZkvyv/8RCnGc12Mhj5VcSa Y11xJKEFkMEHaTuwvIees6C0vF80TqJu+a9jClbMD/r8qet9ehu4Y+EQlzzRklnvzlhn 4HRtqRMW6/YEYEQqWiHbPbVdAfYCQioiWIkvEzp6W90dHKBNU4amFehkqY+/rLKofZss ET3fAvseDVFbcDjkBR271C4K04Y9F7cvFD3LhOZgg5iiECEKmLeqhgOjIDNkyPxN2gYh zrAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ei7KWbmf; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14-20020a50ba8e000000b00450f5384073si784551ede.527.2022.09.29.17.29.13; Thu, 29 Sep 2022 17:29:38 -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=@kernel.org header.s=k20201202 header.b=Ei7KWbmf; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbiI2Xxx (ORCPT + 99 others); Thu, 29 Sep 2022 19:53:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbiI2Xxu (ORCPT ); Thu, 29 Sep 2022 19:53:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B4111CE621; Thu, 29 Sep 2022 16:53:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DA578621F2; Thu, 29 Sep 2022 23:53:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68F59C433C1; Thu, 29 Sep 2022 23:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664495627; bh=zGoeBEsQFYR1XddbT/4DDXBJnqm/WcRswhc2BoBKNsM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ei7KWbmfxEJw0h3HBiNrGSOWNuOiEfbtjZ6aLz3C+GQXZYR5ZkazD9oPv0kBuK1n7 W2jsgUdNNk/ewDV565eh/s05q8gpUQRiWl2sFn+jNlH6ZpebjUsbMNwzXaw/gVQJ2x fJ8b96KylIqy1qU1FK18niUAimozIpikL3DDS9cvmlUx0V5FYCtt3bSKEO2We0eTUI 5PKr/gKxyey9anLVcOyVoSUNBRiZGBnSctC6mG5ABKMJ6Ld6GZQ9UhoZVrjGm7JRh7 4h6JdMMfrEvifxwtr0+lwDbXMynTptHBnu4QF0xGsHAYBfcwyjFkpbQ1OcMhwQfg/E qXYS07xGLV4Gg== Date: Thu, 29 Sep 2022 17:53:43 -0600 From: Keith Busch To: Serge Semin Cc: Jens Axboe , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Thomas Bogendoerfer , linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] nvme-hwmon: Return error on kzalloc failure Message-ID: References: <20220929224648.8997-1-Sergey.Semin@baikalelectronics.ru> <20220929224648.8997-2-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929224648.8997-2-Sergey.Semin@baikalelectronics.ru> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Fri, Sep 30, 2022 at 01:46:46AM +0300, Serge Semin wrote: > Inability to allocate a buffer is a critical error which shouldn't be > tolerated since most likely the rest of the driver won't work correctly. > Thus instead of returning the zero status let's return the -ENOMEM error > if the nvme_hwmon_data structure instance couldn't be created. Nak for this one. The hwmon is not necessary for the rest of the driver to function, so having the driver detach from the device seems a bit harsh. The driver can participate in memory reclaim, so failing on a low memory condition can make matters worse. The rest looks good, though. > @@ -230,7 +230,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) > > data = kzalloc(sizeof(*data), GFP_KERNEL); > if (!data) > - return 0; > + return -ENOMEM; > > data->ctrl = ctrl; > mutex_init(&data->read_lock); > --