From patchwork Tue Sep 29 11:00:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 263169 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=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 9D831C4727C for ; Tue, 29 Sep 2020 11:57:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56F9220706 for ; Tue, 29 Sep 2020 11:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601380667; bh=nZ8K28kV1F/DD/Y6ElHQ6Z9lJp0HvFVmUg4SCS+m1ZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vldhXpEVwK/K+gu8XujAz3w4PUNbLmZpuQVnmNL8odBoPszjmHWmokvOHh31cCnNc EUiV5SKlNm9uCHN/1zlzuLPMs+/yBIHs4/tG9toiHvhZ1QYzNdVPwObq4gkHVZIqdS q5UzDIvYJWaDMRoj3UJ0EtsNIWkXYV14+kaf7j2w= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730672AbgI2Lmv (ORCPT ); Tue, 29 Sep 2020 07:42:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:39928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730714AbgI2Lm0 (ORCPT ); Tue, 29 Sep 2020 07:42:26 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C34B206A5; Tue, 29 Sep 2020 11:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379745; bh=nZ8K28kV1F/DD/Y6ElHQ6Z9lJp0HvFVmUg4SCS+m1ZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JxQ9rflqMb5D+yjJT+HtmEZfshiIUI+VCVaTS+Lya4cZu+IMM7FP3dUJ7SVo5nNf3 xkiWoHyVoVWiZyjTJZ1bMXAqsktgSQ0s8IDJm/FRvqu4CUKJ5jUkQUEkLc+RLDhxTT 9BO9E0pX2ktPNF8k1EwDKvIZVajtShEWQUyeGkZ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Brezillon , Ron Minnich , Richard Weinberger , Sasha Levin Subject: [PATCH 5.4 300/388] mtd: parser: cmdline: Support MTD names containing one or more colons Date: Tue, 29 Sep 2020 13:00:31 +0200 Message-Id: <20200929110024.985059032@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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;