From patchwork Tue Jan 8 19:36:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 1948001 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by patchwork1.kernel.org (Postfix) with ESMTP id CA6E13FED4 for ; Tue, 8 Jan 2013 19:40:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r08JakDe021776; Tue, 8 Jan 2013 14:36:47 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r08Jaj9L011360 for ; Tue, 8 Jan 2013 14:36:45 -0500 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r08JaiUk026527 for ; Tue, 8 Jan 2013 14:36:45 -0500 Received: from sabe.cs.wisc.edu (sabe.cs.wisc.edu [128.105.6.20]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r08Jahxr021851 for ; Tue, 8 Jan 2013 14:36:44 -0500 Received: from fio-mnc.int.fusionio.com (c-24-245-27-162.hsd1.mn.comcast.net [24.245.27.162]) (authenticated bits=0) by sabe.cs.wisc.edu (8.14.1/8.14.1) with ESMTP id r08Jadpm001237 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 8 Jan 2013 13:36:42 -0600 From: michaelc@cs.wisc.edu To: dm-devel@redhat.com, christophe.varoqui@gmail.com Date: Tue, 8 Jan 2013 13:36:34 -0600 Message-Id: <1357673794-4894-1-git-send-email-michaelc@cs.wisc.edu> X-RedHat-Spam-Score: -1.899 (BAYES_00,RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 1/1] libmultipath: fix segfault when vector is null X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com From: Mike Christie While performing tests that caused paths to get added and deleted, we hit a segfault. We traced it to the vector struct being NULL. This patch fixes the problem by checking for a NULL vector before accessing it. Signed-off-by: Mike Christie --- libmultipath/vector.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmultipath/vector.c b/libmultipath/vector.c index 652f118..0564224 100644 --- a/libmultipath/vector.c +++ b/libmultipath/vector.c @@ -94,6 +94,9 @@ find_slot(vector v, void * addr) { int i; + if (!v) + return -1; + for (i = 0; i < (v->allocated / VECTOR_DEFAULT_SIZE); i++) if (v->slot[i] == addr) return i;