Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
From: Dave Jiang <djiang@mvista.com>
To: drbd-dev@lists.linbit.com
Subject: [Drbd-dev] drbdadm segfaults with incorrect drbd.conf
Date: Wed, 20 Jun 2007 09:34:03 -0700	[thread overview]
Message-ID: <467956FB.5060507@mvista.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

It seems that when the resources aren't setup exactly right in drbd.conf
drbdadm can segfault due to using a pointer that is NULL. Attached is a patch
that fixes the issue.

-- 

------------------------------------------------------
Dave Jiang
Software Engineer
MontaVista Software, Inc.
http://www.mvista.com
------------------------------------------------------


[-- Attachment #2: drbd_check_valid_ptr.patch --]
[-- Type: text/x-patch, Size: 806 bytes --]

diff -Naurp drbd-8.0.3/user/drbdadm_main.c drbd-8.0.3-mod/user/drbdadm_main.c
--- drbd-8.0.3/user/drbdadm_main.c	2007-05-02 02:13:37.000000000 -0700
+++ drbd-8.0.3-mod/user/drbdadm_main.c	2007-06-20 09:27:45.000000000 -0700
@@ -1029,6 +1029,7 @@ struct d_resource* res_by_minor(const ch
   mm = m_strtoll(id+6,1);
 
   for_each_resource(res,t,config) {
+    if( !res->me ) continue;
     if( mm == dt_minor_of_dev(res->me->device)) return res;
   }
   return NULL;
@@ -1818,7 +1819,9 @@ int main(int argc, char** argv)
 
     highest_minor=0;
     for_each_resource(res,tmp,config) {
-      int m = dt_minor_of_dev(res->me->device);
+      int m;
+      if ( !res->me ) continue;
+      m = dt_minor_of_dev(res->me->device);
       if ( m > highest_minor ) highest_minor = m;
       nr_resources++;
     }

             reply	other threads:[~2007-06-20 16:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-20 16:34 Dave Jiang [this message]
2007-06-20 17:32 ` [Drbd-dev] drbdadm segfaults with incorrect drbd.conf Philipp Reisner
     [not found]   ` <46796D1E.5090105@mvista.com>
2007-06-25 14:07     ` Philipp Reisner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=467956FB.5060507@mvista.com \
    --to=djiang@mvista.com \
    --cc=drbd-dev@lists.linbit.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox