From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D4D3C43463 for ; Fri, 18 Sep 2020 02:18:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAC4A23600 for ; Fri, 18 Sep 2020 02:18:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395505; bh=3T9CsaQ3l2wYOtqtsfLNFqmg+/ln9/Tg2eV+eIuG2Mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=A8X6ITr9UI/oHzf+JlubqGLY9kqMwoIa/cg+yfMkCQVdBrRTIN4Be/EMmsLe7q2gn rxWVbkiP26/D3guBiHvySfV4kdBFVm5cigAZNeFK7oG7TFb9aQWJsPYhjcoUQuFYlF PTQfqVpUssdbMRVjJxFFRmyqvZcO4oTOChVsKTJ8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729679AbgIRCSZ (ORCPT ); Thu, 17 Sep 2020 22:18:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:49066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729631AbgIRCR6 (ORCPT ); Thu, 17 Sep 2020 22:17:58 -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 D32F1238EE; Fri, 18 Sep 2020 02:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395477; bh=3T9CsaQ3l2wYOtqtsfLNFqmg+/ln9/Tg2eV+eIuG2Mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e8OS0R0N53+dOIy7CSsp4FhVZlScDfTbzeHE1QymJ8eLprTwOHuZ/wKtMAdblEorL e9lLmsZVmNK2gNw7h3Kx47h49QQ1fIEi8nYCvpZY4uO1MK2pGPbDPxQAt39CAO/qd5 Cdiv82ShNawdei2tO1XAYsxoZ29fEh5D0jyhgsMs= 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 4.4 61/64] mtd: parser: cmdline: Support MTD names containing one or more colons Date: Thu, 17 Sep 2020 22:16:40 -0400 Message-Id: <20200918021643.2067895-61-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021643.2067895-1-sashal@kernel.org> References: <20200918021643.2067895-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/cmdlinepart.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index 08f62987cc37c..ffbc9b304beb2 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c @@ -228,12 +228,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