Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751817AbbFZGir (ORCPT ); Fri, 26 Jun 2015 02:38:47 -0400 Received: from mga11.intel.com ([192.55.52.93]:36948 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750729AbbFZGik (ORCPT ); Fri, 26 Jun 2015 02:38:40 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,682,1427785200"; d="scan'208";a="717987355" Message-ID: <558E4462.7060600@intel.com> Date: Sat, 27 Jun 2015 14:36:18 +0800 From: Pan Xinhui User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org CC: akpm@linux-foundation.org, linux@rasmusvillemoes.dk, tj@kernel.org, mnipxh@163.com Subject: [PATCH] lib/bitmap.c: add some check to correct the parse result Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1026 Lines: 33 Sometimes the input from user may cause an unexpected result. for example, echo "1-3," > /proc/irq//smp_affinity_list. The correct result should be 1-3, however we got 0-4. To avoid this issue, we check if there is a ready digit. If no valid digit is set, we just continue to the next parse. Signed-off-by: Pan Xinhui --- lib/bitmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/bitmap.c b/lib/bitmap.c index 64c0926..3c489c1 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -561,6 +561,8 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, return -EINVAL; if (b >= nmaskbits) return -ERANGE; + if (unlikely(exp_digit)) + continue; while (a <= b) { set_bit(a, maskp); a++; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/