From patchwork Thu May 28 04:04:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6495851 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0BA28C0020 for ; Thu, 28 May 2015 04:04:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1554D2071B for ; Thu, 28 May 2015 04:04:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E8F220719 for ; Thu, 28 May 2015 04:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750756AbbE1EEO (ORCPT ); Thu, 28 May 2015 00:04:14 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35486 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169AbbE1EEO (ORCPT ); Thu, 28 May 2015 00:04:14 -0400 Received: by pacwv17 with SMTP id wv17so13559633pac.2 for ; Wed, 27 May 2015 21:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=68wEsQQ1Po22ckiqESVvHCRFciTobYjKMBhmsgYuH0c=; b=sO8Fq2duKUhfYBE3lELFjHIVhMb/d4OQNQOrcFtW92S53gJQGZxQAp3jsSDj0TTqHp Tv7ob2Sq+jFH6yruV+nRi0lQRHdvTzJtvOAblBhX1mhbRPboF7ZDyy77RKVPk6RXOHI/ LuJ9iL/miIJZ0QxhB9jA2rnRE1izG+s269oqyE0x8JwNe2Ede1Y0tcK+m2t6gVLX/tLD noE2rs/ohHNJJ8RMhnbJPfk60hE5S6hXLvF26ygvl1X1E+N3Ogvtz1JN4wjrKTNMqu9I 2DFLo4PBCou7EqjhRdZhd0PHspNOl+IqvQc5B4DQ+Gjz5BL/FRFA1yLPSLtE0gd4w0iI djqQ== X-Received: by 10.67.2.98 with SMTP id bn2mr1547699pad.83.1432785853717; Wed, 27 May 2015 21:04:13 -0700 (PDT) Received: from [192.168.99.15] ([104.143.41.79]) by mx.google.com with ESMTPSA id ki3sm676862pdb.74.2015.05.27.21.04.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 May 2015 21:04:13 -0700 (PDT) Message-ID: <556693B7.6040501@gmail.com> Date: Thu, 28 May 2015 12:04:07 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Steve Dickson CC: "linux-nfs@vger.kernel.org" , Christoph Hellwig , kinglongmee@gmail.com Subject: [PATCH] blkmapd: Fix infinite loop when reading serial Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If (dev_id->ids & 0xf) < current_id, must updates pos when continue. Otherwise an infinite loop. No other places use the pos value, just move to the top of while. Signed-off-by: Kinglong Mee --- utils/blkmapd/device-inq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/blkmapd/device-inq.c b/utils/blkmapd/device-inq.c index c5bf71f..6b56b67 100644 --- a/utils/blkmapd/device-inq.c +++ b/utils/blkmapd/device-inq.c @@ -196,6 +196,8 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename) while (pos < (len - devid_len)) { dev_id = (struct bl_dev_id *)&(dev_root->data[pos]); + pos += (dev_id->len + devid_len); + if ((dev_id->ids & 0xf) < current_id) continue; switch (dev_id->ids & 0xf) { @@ -226,7 +228,6 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename) } if (current_id == 3) break; - pos += (dev_id->len + devid_len); } out: if (!serial_out)