Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp854292pxk; Thu, 17 Sep 2020 19:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5HB9aty58XUJQS+XpXHuSCBp3+g4ooSUHbgLqPa8FHqbdanT/47bDlcYflVwnvh6+c40g X-Received: by 2002:a05:6402:1acf:: with SMTP id ba15mr34170692edb.305.1600395029099; Thu, 17 Sep 2020 19:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600395029; cv=none; d=google.com; s=arc-20160816; b=YDINTTlgtMCviL+VX0Lqvo34aMcGjWyk5i+cCf0gCgm3AJkfq7A2FNlmId7SCEn8s/ 89F9peoh/Luai3PAeVn+ShwywLm/v2LOBN+Mc0MKuiRgt443y2PqM17d66zZAKIpVTHc LJeJ+3uqUCv39kZl4U87KD0SpZ9yG2jySu89ulfFFQGMKB3n1Q3kd1Xg3lGvzokQQ+oJ yCbOqPwfIgTgzFuZKdFhLJc6Ve+TYATV0OYFUyEFylIHvxdbPWo/mZ26iyHSZ630QPV4 SVX+tB+orUIimD703PECX87NaElPjUYlgVxMUdLzfgqdG9tfRB9dGkqOz93idgNOks0P SQ+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tLIVstevt8vbLdTO0NKZF2JCq1yKhOYs/8kMoupnQy0=; b=IWnX6EkyVI+Dp0JMYvG8CQFUzf7ZeCcQ4Qw6VpfgFSFUWJjYT8NMwpW0WoNnN9HEcr 4rHOvJaTzxJb+qioZd3xZo93PtCp/PtjhMf/zDQ7u9Tic+W6+u95jfaHcOqXmOVTlae7 AJv5A9xCRaaGzJswxokBkHHqY/xsjubyzkfHbyKXgax08iKScGrUII25lcxtzJ9SVSIx Y84bFxtEROuH6o2dP9FKaONB5iJFY0aR+X90/FxEzjjKfX+vWISWLz28SI3qAVXxFnc/ CNucVvhHogR4H2WIuwWzU/24YNu/zQuoQvjiCaedeJj5ZaKda/keF2H0mrDR2EzTPE1S MhiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=glmbp43t; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h2si1157820ejy.315.2020.09.17.19.10.05; Thu, 17 Sep 2020 19:10:29 -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=pass header.i=@kernel.org header.s=default header.b=glmbp43t; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbgIRCH7 (ORCPT + 99 others); Thu, 17 Sep 2020 22:07:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:57994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbgIRCHf (ORCPT ); Thu, 17 Sep 2020 22:07:35 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 083B92395C; Fri, 18 Sep 2020 02:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394854; bh=nZ8K28kV1F/DD/Y6ElHQ6Z9lJp0HvFVmUg4SCS+m1ZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=glmbp43tjxgSKgkMFL/BS8aSxmHrZSBQavF9lBcDSra62LYooqJyD1kTNLAgcLwQ7 Ueg/wGYaN/oCxsbCt80x4EDLK9g7K+9zSxxjtqf9zJps0AwmeIjgXdv/rTcXWHPAd5 /F4q457mGzSsh6nuDUF0wi0W10CY2oe2hHv+bNzE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Boris Brezillon , Ron Minnich , Richard Weinberger , Sasha Levin , linux-mtd@lists.infradead.org Subject: [PATCH AUTOSEL 5.4 309/330] mtd: parser: cmdline: Support MTD names containing one or more colons Date: Thu, 17 Sep 2020 22:00:49 -0400 Message-Id: <20200918020110.2063155-309-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boris Brezillon [ Upstream commit eb13fa0227417e84aecc3bd9c029d376e33474d3 ] 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 Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- 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 c86f2db8c882d..0625b25620ca7 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; -- 2.25.1