From: "Benjamin Marzinski" Subject: [PATCH 08/15] libmutipath: allow blanks in device blacklist Date: Sat, 7 Mar 2015 21:31:39 -0600 Message-ID: <1425785506-20419-9-git-send-email-bmarzins@redhat.com> References: <1425785506-20419-1-git-send-email-bmarzins@redhat.com> Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1425785506-20419-1-git-send-email-bmarzins@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: device-mapper development Cc: Christophe Varoqui List-Id: dm-devel.ids As Brian De Wolf noticed, multipath crashes if you don't have both vendor and product specified in a device blacklist entry. This patch makes device blacklists work when either the vendor or the product is blank. If both are missing, the entry is ignored. Signed-off-by: Benjamin Marzinski --- libmultipath/blacklist.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libmultipath/blacklist.c b/libmultipath/blacklist.c index 3f9e80b..05f1697 100644 --- a/libmultipath/blacklist.c +++ b/libmultipath/blacklist.c @@ -135,8 +135,12 @@ _blacklist_exceptions_device(vector elist, char * vendor, char * product) struct blentry_device * ble; vector_foreach_slot (elist, ble, i) { - if (!regexec(&ble->vendor_reg, vendor, 0, NULL, 0) && - !regexec(&ble->product_reg, product, 0, NULL, 0)) + if (!ble->vendor && !ble->product) + continue; + if ((!ble->vendor || + !regexec(&ble->vendor_reg, vendor, 0, NULL, 0)) && + (!ble->product || + !regexec(&ble->product_reg, product, 0, NULL, 0))) return 1; } return 0; @@ -149,8 +153,12 @@ _blacklist_device (vector blist, char * vendor, char * product) struct blentry_device * ble; vector_foreach_slot (blist, ble, i) { - if (!regexec(&ble->vendor_reg, vendor, 0, NULL, 0) && - !regexec(&ble->product_reg, product, 0, NULL, 0)) + if (!ble->vendor && !ble->product) + continue; + if ((!ble->vendor || + !regexec(&ble->vendor_reg, vendor, 0, NULL, 0)) && + (!ble->product || + !regexec(&ble->product_reg, product, 0, NULL, 0))) return 1; } return 0; -- 1.8.3.1