From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162649AbbKTKSB (ORCPT ); Fri, 20 Nov 2015 05:18:01 -0500 Received: from a.ns.miles-group.at ([95.130.255.143]:11949 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162654AbbKTKR6 (ORCPT ); Fri, 20 Nov 2015 05:17:58 -0500 Subject: Re: [PATCH] UBI: fix return error code To: Sudip Mukherjee , Artem Bityutskiy , David Woodhouse , Brian Norris References: <1448014460-1371-1-git-send-email-sudipm.mukherjee@gmail.com> Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org From: Richard Weinberger Message-ID: <564EF353.2050806@nod.at> Date: Fri, 20 Nov 2015 11:17:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <1448014460-1371-1-git-send-email-sudipm.mukherjee@gmail.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 20.11.2015 um 11:14 schrieb Sudip Mukherjee: > We are checking dfs_rootdir for error value or NULL. But in the > conditional ternary operator we returned -ENODEV if dfs_rootdir contains > an error value and returned PTR_ERR(dfs_rootdir) if dfs_rootdir is NULL. > So in the case of dfs_rootdir being NULL we actually assigned 0 to err > and returned it to the caller implying a success. > Lets return -ENODEV when dfs_rootdir is NULL else return > PTR_ERR(dfs_rootdir). > > Signed-off-by: Sudip Mukherjee > --- > drivers/mtd/ubi/debug.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c > index b077e43..c4cb15a 100644 > --- a/drivers/mtd/ubi/debug.c > +++ b/drivers/mtd/ubi/debug.c > @@ -236,7 +236,7 @@ int ubi_debugfs_init(void) > > dfs_rootdir = debugfs_create_dir("ubi", NULL); > if (IS_ERR_OR_NULL(dfs_rootdir)) { > - int err = dfs_rootdir ? -ENODEV : PTR_ERR(dfs_rootdir); > + int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV; > Nice catch! Thanks, //richard