Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3473795pxy; Mon, 26 Apr 2021 02:37:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSc40p2piPcdf5dEbfL4URInziXSyW0sSyJ4mUy0osw3byVTKp0GJ5NT4782hjDfQEiO2W X-Received: by 2002:a05:6402:26ca:: with SMTP id x10mr20138552edd.386.1619429830516; Mon, 26 Apr 2021 02:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619429830; cv=none; d=google.com; s=arc-20160816; b=mTzs/Fef/CBb1DS7iL/nq6NTrIoFgeu20lM7YJCcocn6U3Vv3OEvWIrC4z/4XXfTAN ztZmWksLKmECxseLRK3wfUbPHukCsYyRbru7aMCQq7JZOvW5dWC5HojyIM1ijtobepf2 J0TYCEKNmObr39Gwit3nd6zCziyhVYMjSoNwXBBUEUD6ISzoL2daCn5K0cEVSzMgByd7 EPb5pFAlgyJRQ3nJ9EKbFIgyGudtxVO/GXYzbRPtD8O08JTo+mweiGNOhsaBYMkXpFHH 0GNKR/9EvU6T098NiZ3c63TpVDKtYibrwoIdJtgJTdKfxG+RO2LIRk4Zn9m8ThbiE1dP /VFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=SewEIJLB4CBWLDqJmBR3fF5f+WJRSXPFliLpN9wht8M=; b=qXocPDMf0iuTwZG2G3ib8cXuEgzQPmHWXgTQ5kKS+6LjKV52cHLbEJB93u1yMXeUP2 NF/hHiz3k9difz+H9yWLHges+uhcE9qLvNJh7uyJY2ycVltK+HqjCs2rIF8C6rFa7cbi 3kAN/IxC0FoYZ7IFV036vxEhEKeBHsjpmWsl4pXp37vRk8vlMQTNz5rOi0wf1IJ9vmbh Q492ve8287sf4AWYNXk1BOvWrkW3yYRCk99ng32ZH36YEjBB+aOGT6f643SAV/EyE+8o 5FxIMlYfhBufP8/eid7g67cVTNxIJeUZJOoLJcBwxGsp2L+AW+EiwA9iIz0FILJ0TbGa oSVg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si16872550edd.352.2021.04.26.02.36.47; Mon, 26 Apr 2021 02:37:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233033AbhDZJd3 (ORCPT + 99 others); Mon, 26 Apr 2021 05:33:29 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:60024 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232871AbhDZJdP (ORCPT ); Mon, 26 Apr 2021 05:33:15 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=yang.lee@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0UWpMjTz_1619429550; Received: from j63c13417.sqa.eu95.tbsite.net(mailfrom:yang.lee@linux.alibaba.com fp:SMTPD_---0UWpMjTz_1619429550) by smtp.aliyun-inc.com(127.0.0.1); Mon, 26 Apr 2021 17:32:31 +0800 From: Yang Li To: miquel.raynal@bootlin.com Cc: richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Yang Li Subject: [PATCH] mtd: return -ENOMEM when kmalloc failed Date: Mon, 26 Apr 2021 17:32:23 +0800 Message-Id: <1619429543-52234-1-git-send-email-yang.lee@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver is using -1 instead of the -ENOMEM defined macro to specify that a buffer allocation failed. Using the correct error code is more intuitive Smatch tool warning: drivers/mtd/inftlmount.c:333 check_free_sectors() warn: returning -1 instead of -ENOMEM is sloppy drivers/mtd/nftlmount.c:272 check_free_sectors() warn: returning -1 instead of -ENOMEM is sloppy No functional change, just more standardized. Reported-by: Abaci Robot Signed-off-by: Yang Li --- drivers/mtd/inftlmount.c | 2 +- drivers/mtd/nftlmount.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c index af16d34..39d0241 100644 --- a/drivers/mtd/inftlmount.c +++ b/drivers/mtd/inftlmount.c @@ -330,7 +330,7 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address, buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL); if (!buf) - return -1; + return -ENOMEM; ret = -1; for (i = 0; i < len; i += SECTORSIZE) { diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c index 444a77b..fd331bc 100644 --- a/drivers/mtd/nftlmount.c +++ b/drivers/mtd/nftlmount.c @@ -269,7 +269,7 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL); if (!buf) - return -1; + return -ENOMEM; ret = -1; for (i = 0; i < len; i += SECTORSIZE) { -- 1.8.3.1