From patchwork Fri May 27 09:58:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Animesh K Trivedi1 X-Patchwork-Id: 823422 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4R9wHvb015268 for ; Fri, 27 May 2011 09:58:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757391Ab1E0J6R (ORCPT ); Fri, 27 May 2011 05:58:17 -0400 Received: from mtagate6.uk.ibm.com ([194.196.100.166]:35094 "EHLO mtagate6.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752867Ab1E0J6Q (ORCPT ); Fri, 27 May 2011 05:58:16 -0400 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate6.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p4R9wErO010084 for ; Fri, 27 May 2011 09:58:14 GMT Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4R9wEpF2461772 for ; Fri, 27 May 2011 10:58:14 +0100 Received: from d06av06.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4R9wELf014442 for ; Fri, 27 May 2011 03:58:14 -0600 Received: from d12mc302.megacenter.de.ibm.com (d12mc302.megacenter.de.ibm.com [9.149.170.82]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4R9wDR9014432; Fri, 27 May 2011 03:58:13 -0600 Subject: [PATCH] Fixing segfault in libibverbs X-KeepSent: C348E58C:B4C03447-C125789D:0035F094; type=4; name=$KeepSent To: Roland Dreier , linux-rdma@vger.kernel.org Cc: Bernard Metzler X-Mailer: Lotus Notes Release 8.0.2 HF623 January 16, 2009 Message-ID: From: Animesh K Trivedi1 Date: Fri, 27 May 2011 11:58:13 +0200 X-MIMETrack: Serialize by Router on D12MC302/12/M/IBM(Release 8.5.2FP1|November 29, 2010) at 27/05/2011 11:58:13 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 27 May 2011 09:58:18 +0000 (UTC) Hi, This patch fixes SEGFAULT in libibverbs in case when there are no user space drivers found. I've cloned the libibverbs from git://git.openfabrics.org/ofed_1_1_5/libibverbs.git (I hope this is correct) Example: rping gets segmentation fault in libibverbs when there are no user space drivers found. Here is the output $ rping -s libibverbs: Warning: no userspace device-specific driver found for /sys/class/infiniband_verbs/uverbs0 Segmentation fault rping[28471]: segfault at 3 ip 00007f20c5a51ca6 sp 00007fffddc22b80 error 4 in libibverbs.so.1.0.0[7f20c5a4b000+c000] This is caused by corrupt pointers, driver_name_list and sysfs_dev_list. They are used in maintaining the head of the link list but are not re-initialized to NULL in between the invocations. The previous stale address values are used in read_config() and find_sysfs_dev() calls. Although I am not sure if calls to rdma_create_event_channel() and rdma_create_id() (in rping) should succeed, if there are no user space drivers. That is why there are multiple invocations to ibverbs_init(). Thanks, --- Animesh Signed-off-by: Animesh Trivedi -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/src/init.c b/src/init.c index 4f0130e..45c360f 100644 --- a/src/init.c +++ b/src/init.c @@ -232,6 +232,7 @@ static void load_drivers(void) free(name->name); free(name); } + driver_name_list=NULL; } static void read_config_file(const char *path) @@ -536,6 +537,7 @@ out: } free(sysfs_dev); } + sysfs_dev_list=NULL; return num_devices; }