Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1635172pxv; Fri, 2 Jul 2021 08:29:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxb8b7Gfrk43ue6KRL2b2mGhkHbXSuFPP0hlSrZM7kl1w34BXutLylft8hnCVOeMK5nKu+e X-Received: by 2002:a05:6402:348c:: with SMTP id v12mr46799edc.86.1625239769405; Fri, 02 Jul 2021 08:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625239769; cv=none; d=google.com; s=arc-20160816; b=EX5Wu9uCK2cFZ5LzSNDbessfLDyYmVtpzWquZfUpHmn2n3Kf2D05lN5OmnXxTvqvxp jzFbFYjCtSoQhxiVfPjrLzqHUxLExPRPiBoQGfKNihL67HeZXd6qEXW8vk17PUYTX2ih 1RWs2MULx6Lm+nYJ25NyC4Q6WqzjEhMDjlGXnjgmfhcrB76JUT/KlRi6vVTBkad9jRdv Hz4wUOsbo/dBG9leKvdilx5nKW2tJ6OEffwhADNtWmQRkwxZa/I5EGeZyzZC1JWNXi4Q 1WeycAzx9zcGsq2Izvqt4j2POwMMxDFeP5W2TuggsOEI+Xwer2WhWGM2C/pS3YBJsdB4 5zTw== 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=dQ6foskfq7w8jvqIoFoprgyjuaE22FciyoRHatruQQI=; b=L779A/Xd2VUNhvlLgO8GCZTiJKKEFFNz1EUCar5F179QxardoxoRZWDgDvIT1/K74D f4n2IGS2WFCHGYYXKYQOpWmr8ApMxZEv9AItc4fhtrekhm9YFIomahNFfio87X8t6gpd yVIp5+5jfYr4xDcByw77/rWaRBom1R28yAMHHXTN/+Byv/Rq1e0B6xwk+kJEAR5HAVkN JwfbVET3Y5fKG5TSI8kq5G8dyZ6PC4B/fjeTf/m2mr8sECtM11TByC1Vl2kBOxRIs/f9 n/deVUo49bXZuU0iX4QNVusSvftADBMRZf3H7f55W3P5KV4E1x0O8jzeu6wW8w3/8GXq fgqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dlvppMt6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f26si3310583edy.22.2021.07.02.08.29.05; Fri, 02 Jul 2021 08:29:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dlvppMt6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232645AbhGBOqm (ORCPT + 99 others); Fri, 2 Jul 2021 10:46:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:59328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230424AbhGBOqm (ORCPT ); Fri, 2 Jul 2021 10:46:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 94FFF613FE; Fri, 2 Jul 2021 14:44:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1625237050; bh=tQbOmOYm52sqPdnKBHSq7Q8mipiiNLQCBkJZv7Ts5mo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dlvppMt6J9x4cFjD5sqPNkUFLKCc9HNF+xb6trH2ja/+l+bnmCQEJT0naFGH93Z/+ 6qHD1i8IIOlwo0P/waN3WyAC1uC7MlOY5UeQCfPThtca4FM7Y4/USFA3PNV2WFGWkn ksAGsl2c+dnK6GvCvPEZFUHS8PiRncYQby6eH64Q= Date: Fri, 2 Jul 2021 16:44:07 +0200 From: Greg KH To: Salah Triki Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] dio: return -ENOMEM when kzalloc() fails Message-ID: References: <20210702133114.GA314157@pc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210702133114.GA314157@pc> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 02, 2021 at 02:31:14PM +0100, Salah Triki wrote: > Return -ENOMEM when kzalloc() fails in order to inform the caller of the > failure. > > Signed-off-by: Salah Triki > --- > drivers/dio/dio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c > index 193b40e7aec0..4c06c93c93d3 100644 > --- a/drivers/dio/dio.c > +++ b/drivers/dio/dio.c > @@ -219,7 +219,7 @@ static int __init dio_init(void) > /* Found a board, allocate it an entry in the list */ > dev = kzalloc(sizeof(struct dio_dev), GFP_KERNEL); > if (!dev) > - return 0; > + return -ENOMEM; Do you have this hardware to test with? While this patch looks correct, it still is leaking lots of resources if this every happens. Can you fix this up "properly" so that all of the resources allocated at this point in time will be correctly freed? Or, really, this is an impossible error path to hit, given that it is at boot time, so maybe it's just not worth it given that I doubt anyone has this hardware... thanks, greg k-h