From patchwork Thu Dec 23 02:24:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L5pOO?= X-Patchwork-Id: 12697886 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21DF7C433F5 for ; Thu, 23 Dec 2021 02:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231168AbhLWCYW (ORCPT ); Wed, 22 Dec 2021 21:24:22 -0500 Received: from mail-eopbgr1300090.outbound.protection.outlook.com ([40.107.130.90]:9136 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229788AbhLWCYV (ORCPT ); Wed, 22 Dec 2021 21:24:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ze0W+2zgDqBHOEXYTfdjaynFxzW1TlsD+oUDh0ODKbIj/vslxJodbZps0Ak1OwJxqJB4FCokxN4NDLjVNI14Q18Gk7VsD3P+B3WeQvy6DbW99zo8NuL99+qbBm3esbgTMz38IrYEAV6HS2FZR65ZdrlMBQzwTwfQZ/yYreh5PsD9XkTX2qTRG0ox2kyQiG5iKAMWoZyrrSX9yHl/DmWw8jAqPm1gjtwQ8Pju175njGDNusPfafINkA1d/z+jnpvv4aTKFOQD9BwCdmpNYtoJaUknjQ0O5Mc4bN30O7icEQx3uuY0byLaJjRdZhevfHcwBPFmC024OeA8BeQsXT/xLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rnJKTsowd+Sg5QVFDKKejXMKqwlY/nUa9Dem2F4lJm4=; b=KSmBb5aEMjYnWFpgxQlv4TNu54ksQAgPh7zpfQsrwTp8ICF5h/mr0LQFkFOm8zonXFvX8lNtWGGVlPuw1ifRubYMYowyVT/WkiB121c7Y4DMZxSyJs6c190uFWpvZNALAK78Ackez6l6EeMW33cUMPR1SLzi4Uxl7K7qzcR8m95FAKBvAplue+MqE3KNKi6dClUKw6a3kZ/l0iEaEn1fTEyLeMSXYUjA/NwONhbZXZvGGEKNEzUvoeU7V410vI3+w/oazRN8ySv+CshV5NIkoAY9Bgh6LZ8a6ffCGH8xZ1LjMl61FdvJcKZ+8QChH4teeaLn7+GyM1rw2X9rd81IAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo0.onmicrosoft.com; s=selector2-vivo0-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rnJKTsowd+Sg5QVFDKKejXMKqwlY/nUa9Dem2F4lJm4=; b=jTxQETEcIDjM3IxMdH7saHDyGvaVdI2KCfYqD984IviCiop7hcO4/j3QYTZZ4pGwatEhSvom3ExHDnoCX3t4+FnJeL2C1FLoK+EMUjuxGNHjWMELF2kZZSWuWJvxk03PzS2xeno9ukptP4tsQNaXcNlY81fFr92nXvf/rr+CMww= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) by SL2PR06MB3388.apcprd06.prod.outlook.com (2603:1096:100:3c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.19; Thu, 23 Dec 2021 02:24:16 +0000 Received: from SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4d34:9df8:fabe:fdb2]) by SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4d34:9df8:fabe:fdb2%6]) with mapi id 15.20.4823.019; Thu, 23 Dec 2021 02:24:16 +0000 From: Qing Wang To: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wang Qing Subject: [PATCH] block: return specific error when pointer is NULL Date: Wed, 22 Dec 2021 18:24:03 -0800 Message-Id: <1640226246-32691-1-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 X-ClientProxiedBy: HK2PR02CA0149.apcprd02.prod.outlook.com (2603:1096:202:16::33) To SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e3e87518-6e59-4027-f88a-08d9c5bb512f X-MS-TrafficTypeDiagnostic: SL2PR06MB3388:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:109; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XPlvMN4MGWTUAWeyFHHKGUpJNEtgOsFdcepEh3zrfFZYgWkc9qqjYD8e2PZ4Bgc51c9FH3zNKpOURJcTR+zugU2tBeqlf3VOIHD+DzeiPAoUoNt5jE+y3Bty/juFaND66sCAAE7k/l34DViRVlmvIAKTA1tZARxTfTbLa7goRKRjt++bNT1Xz7TYVtp167QxjTB5oHAMbpA03Kr+UjiY1ztVFNVGk5SK9OypL2434a+c99BE3+3iCExjzBcCo9wbNYrxYQg7hiP7gRhl1HDIt17ILndVwkK/lKYGwdvrSpKwn73iBOHGQiCZXWMVirq9PDT7LRdkMjoiTyVKrQXc/KKFAcu873N+rTgS4l/Otu92hVbl4HgxrHfRQKwixAU1Sm97asdVVpNMw7iDhuvkwx/tepdpT/gXL2KDscgT4ryV4NdFJ6xhFxxu4yqHed47S1jSZFMVcYCGRC8QMXYf1O1v/v022wOicF1kFtIKS5hy3A8ZYh57FHxHe0GJGLIiCtXa4FJqLchA9LAwTY1vOenkZrVjdN50eBNxWQ7eyzR5BkoRIDXjTY+EbVzdDQlmG4cfyGA6+9KixUQ5pupZVjdfnKhoCnB6hOKwklEpTDPKP0Kv6gAOglkYvKrhZbQSQGG0AulA8n427TdR1S4fYpeBbR58Ket0QGZd5Z4FESO+Knd31MUDqkBL4v5VTKY8aM5Mg2yBCqHvk380OOslqw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SL2PR06MB3082.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(66556008)(8676002)(4326008)(36756003)(52116002)(6512007)(26005)(2616005)(66946007)(66476007)(6666004)(8936002)(508600001)(6506007)(86362001)(83380400001)(107886003)(2906002)(38100700002)(38350700002)(5660300002)(316002)(186003)(6486002)(4744005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4VwO02Ab5QP+dFqA2maGgX648caNweIUPwdfjjL8JuxAjxr6VDzUDj0OQ/diFTI6AUvsodh4bU0kgAWatD897azBmabjofcbRK5fqTdnbfC2XClv5z5ECEhZB/Tltt04RgRB8eJh3T5ECuIYIX/DEmEMFCbZA2D8rHCE6918MjWKKuMl7qFlJzRQWqAWRAiplRlRsNgx6xtDYOw2Xfv1gToKKlkVhiM+YwdHZkOt5Jc7UzfHmYCnfKF5nSf/YWKKwu4XWufkc7Xlmj4kqteVIA4FLF4nr2OogyQirI1zzWzvXCYj7+HlON+UaaojuXaHVuUvm59s42pmFLB4KWopydNCED+PDqndhRm/lTT81ihEE8AJuWHs5Xg/u/NGK2rqbJt7ieUeB02bQ8JCbH1bQicuFn0k6oUh6D6b+Zomn0u5r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TLQNELbut6sFn5uj/vur2T7lK7V17+lsykXGOrwbvt648JXmXeRdnop3kglB6c55ZemJ1PWurg2yLv2FsexprVNIG3rVErl8/keZVpH84FvFjw0ZznISho= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3e87518-6e59-4027-f88a-08d9c5bb512f X-MS-Exchange-CrossTenant-AuthSource: SL2PR06MB3082.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2021 02:24:16.3790 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bYbA3BilB0GYyoSyxzGVheq2Byvj8prPMi20qmKMcZ1dE35FMBzBrJ2nQ2xnGTZSjgt19VYoGvJKzdtq3px6dA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SL2PR06MB3388 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Wang Qing loop_attr_backing_file_show() better return specific error than 0 when pointer is NULL Signed-off-by: Wang Qing --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index e52a8a5..860a5b6 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -667,7 +667,7 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf) spin_unlock_irq(&lo->lo_lock); if (IS_ERR_OR_NULL(p)) - ret = PTR_ERR(p); + ret = p ? PTR_ERR(p) : -ENOENT; else { ret = strlen(p); memmove(buf, p, ret);