Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp821221ybz; Wed, 29 Apr 2020 09:59:52 -0700 (PDT) X-Google-Smtp-Source: APiQypJHaCfx32XaJ1sHOwL89cfzHZ3gf3N+5T4JffcvhjVKYmPdirub2zc4kM1zVGWH9XoQr+u4 X-Received: by 2002:a17:906:f208:: with SMTP id gt8mr3692460ejb.124.1588179592013; Wed, 29 Apr 2020 09:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588179592; cv=none; d=google.com; s=arc-20160816; b=ugjevvS/G8Kl4Qmpr1emOeGb5VUS9z1rV4iEMmPrrkwPFRwCjf2DV5lIwc+39Jigvc lXbw6pJKHBPeAdHcKqtU2iVLuRAqFYgTTMLnDn8jVKRsdBEVBUvXQQ2VrK+m3zp8koVq nvH85wwpnhN3qYNthoqfnxL0POLUkmexyhOYX86R2NF4sKdEuthqhbZ9wFQjDkp9HQsL 4EgL23AOjbxOjt5zTjHzHaHsD1ktUsdUgNyONeNIGXCBHwNTezefRLICJe3vrQasJTiS wQg4YGtUlCplx+Yl+xJKibZQ8Foi+AoWlESoRZylqRyLNLW1MGMCq+qdPMqamzMJXWO1 JU4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=QhnNbFgMhb8TBL2bWNur+1czIzeYIF+WjxZSErS6Dcc=; b=DS5CJ2vOMtH2ufr61DqW6OiytlCrPEhKnBMTD5vN7sysAcm3U9ctzAJmHovCB7IKxP 5OCn5IBfOOA/Awxr/F894utnxqBCJV0iQrerH59NcdRqEjIgiaMLWE0xKJTeAP5Q77JI NAf2B/RgDDfZIDQ+FzAhwaciUmiaKo9pAd7j5dKgLzhsl/tYFpcgSdogvTaTTq+2xbhL cGaNSFiOUCLiEGGgEiSYvkyu0VPEl+LKH9jmVZhQh8H7i2S5Utuf1HoB8yUgZQq8Iw4l CzPyLjSwosP+gbwRKSuJYwF7zlM/U0rW6/wk+R2Yx3iaYZfYWxE+DW3R0YRV3vSRbsvI UIlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qOfV4LMX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w22si3942694edu.568.2020.04.29.09.59.29; Wed, 29 Apr 2020 09:59:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qOfV4LMX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbgD2Qy6 (ORCPT + 99 others); Wed, 29 Apr 2020 12:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726580AbgD2Qy4 (ORCPT ); Wed, 29 Apr 2020 12:54:56 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E881C03C1AE for ; Wed, 29 Apr 2020 09:54:56 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id u22so1031867plq.12 for ; Wed, 29 Apr 2020 09:54:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QhnNbFgMhb8TBL2bWNur+1czIzeYIF+WjxZSErS6Dcc=; b=qOfV4LMX6mF2hlEyT6Ogcm2d3yi4foFoOnhf4ENAMAlj6jYw/geKkSo/9zFDah6dgo lN38/MlTvX+q7K6JgPfr3frx3PRHek//4TAKZUCjbBjQWdNjgSP27OjWn89ETA38ZPEU KacFwviDxIG0dxQkIRsSkj82umdS2DHFToJyKKDrBM1R5OR4Q3IuzWiOQ1COtbvmu78e IffnZ4LDpBYxBKZ0IVXvoefLt+JsWVzHdXXLRDiXuDIEnJEJnZdHm7GMJLB2aZzKQuPg nKgStBBd2Ujf/sX2TL3ncD2Os3NfnXLPhdHug+6Bhqa7034rVl5KymN0ymTzTHwFki/N pY4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QhnNbFgMhb8TBL2bWNur+1czIzeYIF+WjxZSErS6Dcc=; b=PRzTmdxWfHf/0oWV/51zBpou6ROlBZ0Hjct9/qNOQqMAX8xCcjavrCu9lzd1Ve2Q0s bGu/ywWGXupC1uKWHVAkJi/78BhcjOcIp+bEPLbYwh4s6KU26REe/F2iLvv6IwMOr7ya l09J2ff44vE7ZNJF+Pcy2xglihdLMRj8zGbKz7/FKOprRzx9ajf+L5JnYmyqHF/iiC0s ucufxJ6Y/Jaaf0k8ghLBSSkbgcBh4oPNZT6ZBcOJvmdNmprBu8mX9qZ3PIZG0aMGeT6a MZQQ+yZkM7h/7LY2a3Uhub+eb5q6SKElonV/l+YHYRi55VGSVKmKjFBvuvB8rP/ibcke g/0Q== X-Gm-Message-State: AGi0PuaYrCEaBFEGyjzav5daIk5f0MLpGlm3DLf//pLTxmVeT8u8saxU KClaQjGb/NK/spsWSztJg8s= X-Received: by 2002:a17:90a:d14d:: with SMTP id t13mr4259685pjw.175.1588179295674; Wed, 29 Apr 2020 09:54:55 -0700 (PDT) Received: from minnich.svl.corp.google.com ([2620:15c:2c5:3:65f9:fd8e:a0b8:2917]) by smtp.googlemail.com with ESMTPSA id w3sm1460190pfn.115.2020.04.29.09.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 09:54:55 -0700 (PDT) From: "Ronald G. Minnich" X-Google-Original-From: "Ronald G. Minnich" Cc: Boris Brezillon , Ron Minnich , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Cyrille Pitchen , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] mtd: parser: cmdline: Support MTD names containing one or more colons Date: Wed, 29 Apr 2020 09:53:47 -0700 Message-Id: <20200429165347.48909-1-rminnich@google.com> X-Mailer: git-send-email 2.26.2.526.g744177e7f7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boris Brezillon Looks like some drivers define MTD names with a colon in it, thus making mtdpart= parsing impossible. Let's fix the parser to gracefully handle that case: the last ':' in a partition definition sequence is considered instead of the first one. Signed-off-by: Boris Brezillon Signed-off-by: Ron Minnich Tested-by: Ron Minnich --- drivers/mtd/parsers/cmdlinepart.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/parsers/cmdlinepart.c b/drivers/mtd/parsers/cmdlinepart.c index c86f2db8c882..0625b25620ca 100644 --- a/drivers/mtd/parsers/cmdlinepart.c +++ b/drivers/mtd/parsers/cmdlinepart.c @@ -218,12 +218,29 @@ static int mtdpart_setup_real(char *s) struct cmdline_mtd_partition *this_mtd; struct mtd_partition *parts; int mtd_id_len, num_parts; - char *p, *mtd_id; + char *p, *mtd_id, *semicol; + + /* + * Replace the first ';' by a NULL char so strrchr can work + * properly. + */ + semicol = strchr(s, ';'); + if (semicol) + *semicol = '\0'; mtd_id = s; - /* fetch */ - p = strchr(s, ':'); + /* + * fetch . We use strrchr to ignore all ':' that could + * be present in the MTD name, only the last one is interpreted + * as an / separator. + */ + p = strrchr(s, ':'); + + /* Restore the ';' now. */ + if (semicol) + *semicol = ';'; + if (!p) { pr_err("no mtd-id\n"); return -EINVAL;