From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.65.1670607881131329069 for ; Fri, 09 Dec 2022 09:44:41 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WyjAPdxN; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 87ADE622E9 for ; Fri, 9 Dec 2022 17:44:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0249C433F0 for ; Fri, 9 Dec 2022 17:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670607880; bh=CliTOW0DVOFZySl4f+kK3ztVNEC3t+DeE39xE5GV/aI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=WyjAPdxN51QyzHwpHCqNd9NlrNKT9jDfrNEW6C/5x0QUGRfPVWHsh7Q9iPGaZfxo2 oYbSUTHI3pn4wjN8qgB1yb6reU/HtX4DpnDijE9BKW5xX+8eF7nxebiQRJgjpVrpu4 XVeVd0/LC0BYN4I/aALtzk1dcDXEEelINlo1poDcqamLYaD/uRH+vbRwFky20nOD+G fPZomuSjjspAJJVmeM8zwfBYJkloWS3PPyETg6qn+pkV/2Gbm78a87wL8YuQfJFAw5 /vgDgXezQVo1AteN/O1cLXqRQ3zpLTkfJ/CxNFuJDq1z0QuS0xpI10k2X3FUgTbpdK FhI9y8Ouivp0A== Received: by mail-lf1-f45.google.com with SMTP id d6so8131138lfs.10 for ; Fri, 09 Dec 2022 09:44:39 -0800 (PST) X-Gm-Message-State: ANoB5pm/xfN/IAp3ebuqL5uTjj00oaVtHp/BOz4cBeWdiXeRzeLioBlx Mb3Q51IqcWUYrMl53XrbsGoqSlktDOJaJXGZ7MM= X-Google-Smtp-Source: AA0mqf6gq2kFchkzuXdmSfJPnFyPVAG9JXUkT9sPC/FurXPcAF9Mac4IMCFnmula7SMkws639nubJJ1m2hgopE9HnE0= X-Received: by 2002:a05:6512:22d4:b0:4b5:6f85:e868 with SMTP id g20-20020a05651222d400b004b56f85e868mr6007584lfu.426.1670607878068; Fri, 09 Dec 2022 09:44:38 -0800 (PST) MIME-Version: 1.0 References: <20221209155943.367-1-michael.d.kinney@intel.com> In-Reply-To: <20221209155943.367-1-michael.d.kinney@intel.com> From: "Ard Biesheuvel" Date: Fri, 9 Dec 2022 18:44:26 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [Patch 1/1] ShellPkg/Shell: Do not set end device path if already end To: Michael D Kinney Cc: devel@edk2.groups.io, Ray Ni , Zhichao Gao Content-Type: text/plain; charset="UTF-8" On Fri, 9 Dec 2022 at 17:00, Michael D Kinney wrote: > > Update Shell Protocol EfiShellGetMapFromDevicePath() to not > set the end if the device path if it is already an end of > entire device path. This removes a write oprtation that can > cause failures if the Device Path Protocol is mapped to > read-only memory. In general Device Path Protocols should not > be modified unless the API explicitly states that the device > path is modified. > > Cc: Ard Biesheuvel > Cc: Ray Ni > Cc: Zhichao Gao > Signed-off-by: Michael D Kinney Reviewed-by: Ard Biesheuvel > --- > ShellPkg/Application/Shell/ShellProtocol.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c > index 509eb60e40f4..e6d20ab16479 100644 > --- a/ShellPkg/Application/Shell/ShellProtocol.c > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > @@ -294,7 +294,13 @@ EfiShellGetMapFromDevicePath ( > *DevicePath = NextDevicePathNode (*DevicePath); > } > > - SetDevicePathEndNode (*DevicePath); > + // > + // Do not call SetDevicePathEndNode() if the device path node is already the > + // end of an entire device path. > + // > + if (!IsDevicePathEnd (*DevicePath)) { > + SetDevicePathEndNode (*DevicePath); > + } > } > > /* > -- > 2.37.1.windows.1 >