Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591AbbDESA0 (ORCPT ); Sun, 5 Apr 2015 14:00:26 -0400 Received: from mail-by2on0059.outbound.protection.outlook.com ([207.46.100.59]:10592 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752010AbbDESAY (ORCPT ); Sun, 5 Apr 2015 14:00:24 -0400 X-Greylist: delayed 3631 seconds by postgrey-1.27 at vger.kernel.org; Sun, 05 Apr 2015 14:00:23 EDT Authentication-Results: spf=pass (sender IP is 63.163.107.173) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none; X-AuditID: ac160a69-f79656d000003967-31-552162653365 Message-ID: <55216262.7000601@sandisk.com> Date: Sun, 5 Apr 2015 18:27:14 +0200 From: Bart Van Assche User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Julia Lawall , Roland Dreier CC: , Sean Hefty , "Hal Rosenstock" , , Subject: Re: [PATCH 12/16] ib_srpt: fix error return code References: <1428235596-4757-1-git-send-email-Julia.Lawall@lip6.fr> <1428235596-4757-13-git-send-email-Julia.Lawall@lip6.fr> In-Reply-To: <1428235596-4757-13-git-send-email-Julia.Lawall@lip6.fr> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeLIzCtJLcpLzFFi42JZI8azSDc1STHUYP0yZYuNmycyWix7cJrR YustaYvLu+awWTw71MtisbOhgcmief0GFgd2j52z7rJ7LN7zkslj06pONo+9W7I8Pm+SC2CN 4rJJSc3JLEst0rdL4MqYM+U4S8FF4YqG7XvZGxg38XcxcnJICJhI3Fw5kR3CFpO4cG89Wxcj F4eQwAlGiVN3VjNCONsZJU5f3McE07FuymEWiMRmRolLvxcxgyR4BbQkfu88zQZiswioSGz6 dQCsgU3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v/bYu3s3TruEW68m480F9rULGiT0m8rfn0nI+WX qDdnQ3/v9/dFHDYePvrbftqqlWeuzT92L33r4/AZ66o+L2PzVHdZLDor8r3v68DNUw4/dFRi Kc5INNRiLipOBADdtBkEFgIAAA== X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:63.163.107.173;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10009020)(6009001)(438002)(189002)(199003)(51704005)(479174004)(24454002)(106466001)(117636001)(65956001)(59896002)(46102003)(92566002)(62966003)(77156002)(36756003)(15975445007)(47776003)(77096005)(19580405001)(19580395003)(50466002)(2950100001)(76176999)(86362001)(575784001)(83506001)(87266999)(54356999)(87936001)(23746002)(50986999)(65816999)(62816006);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR0201MB0974;H:milsmgep12.sandisk.com;FPR:;SPF:Pass;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0201MB0974; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:DM2PR0201MB0974;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0201MB0974; X-Forefront-PRVS: 05373A0663 X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2015 16:27:17.9718 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d;Ip=[63.163.107.173];Helo=[milsmgep12.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0201MB0974 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2682 Lines: 81 On 04/05/15 14:06, Julia Lawall wrote: > Return a negative error code on failure. > > A simplified version of the semantic match that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // > @@ > identifier ret; expression e1,e2; > @@ > ( > if (\(ret < 0\|ret != 0\)) > { ... return ret; } > | > ret = 0 > ) > ... when != ret = e1 > when != &ret > *if(...) > { > ... when != ret = e2 > when forall > return ret; > } > // > > In the first case, the printk is changed to use the ret value, rather > than duplicating PTR_ERR(ch->thread). This requires changing the format > from %ld to %d, to account for the type of ret. > > Signed-off-by: Julia Lawall > > --- > drivers/infiniband/ulp/srpt/ib_srpt.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c > index 6e0a477..5ec98f5 100644 > --- a/drivers/infiniband/ulp/srpt/ib_srpt.c > +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c > @@ -2143,8 +2143,8 @@ retry: > > ch->thread = kthread_run(srpt_compl_thread, ch, "ib_srpt_compl"); > if (IS_ERR(ch->thread)) { > - printk(KERN_ERR "failed to create kernel thread %ld\n", > - PTR_ERR(ch->thread)); > + ret = PTR_ERR(ch->thread); > + printk(KERN_ERR "failed to create kernel thread %d\n", ret); > ch->thread = NULL; > goto err_destroy_qp; > } > @@ -2590,6 +2590,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, > " configured yet for initiator %s.\n", ch->sess_name); > rej->reason = __constant_cpu_to_be32( > SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED); > + ret = -EINVAL; > goto destroy_ib; > } > > @@ -2598,6 +2599,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, > rej->reason = __constant_cpu_to_be32( > SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES); > pr_debug("Failed to create session\n"); > + ret = PTR_ERR(ch->sess); > goto deregister_session; > } > ch->sess->se_node_acl = &nacl->nacl; This is not the proper way to fix srpt_cm_req_recv(). The kthread_run() call must be moved from srpt_create_ch_ib() to after the session registration code in srpt_cm_req_recv(), and the session registration call + the kthread_run() call must be protected via a mutex against concurrent HCA hot-plug removal events (see also srpt_remove_one() and srpt_remove_sdev()). Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/