From patchwork Mon Dec 25 04:43:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 758215 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp2527630wrw; Sun, 24 Dec 2023 20:45:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhneQwjeERK/DgMkabPWrUkNa7IC18R2lPFVcI14RESY5KqoETAxCX4bK9TIQcvMbg3SPk X-Received: by 2002:a05:600c:2201:b0:40c:2d7e:6f72 with SMTP id z1-20020a05600c220100b0040c2d7e6f72mr2725879wml.118.1703479556704; Sun, 24 Dec 2023 20:45:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703479556; cv=none; d=google.com; s=arc-20160816; b=nw0FBUqDQBy6exNt6huFDABEa3eORh9qFkF2tRW9JmOkgSpsXuHkLAEccIyaZ0+DRZ 6RFuOJ4ZYK9jt0OLnifbBeX7Cw8RXRBMnyC+HZSj+nZaZ5SxzJkrzCTEkF6iizOpEdR8 KaERj5udUFLPRbEi2CtbH2uAKLEi3pLy8xFayvrZTsGAwUl8Ds5JWoiMSxHVeSaQ4FJB Vq4rdDiOI5hK2EuwqVOOah7VPTbpHn/RCCNJSkniCiEvek9+26GcztLIhzNo37uN+Jas vi64HszYOLl5bkbO9+XPPe1mCU66k1QludlQrv+qkiqBv1dNvLAadgB1qHdS5x0Yx9VN Iovw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OOtwZXIJ0EGfMVXsfrD6wt75lYzzN7mvK9tS/JxaOqY=; fh=XwOfspvhog7otCudZV1ecvxibH3YToEgjgP70JntENo=; b=HEM3ilTGQAEsATGQ14cTqdftC9AYeM5FedVz8/SU0VCKOpjZrTAVuYeeFd91lpR0to BSe6bkAGc2vPxqXmXVFH21GFp2A5tabX3x0Zv2SDM2SHzINBh413UsU4T7Y71QmQS0oR /EIKko6lGvDjSg313XQyGKTG6N3syHcUZVdiAJqUk8LLaLNcNNdn8INSnID3iWLk8+bK 2m381cmbr31Wj1nLkY2YYS9XuH6+o8mnJ8NjLsMrEkVhssVBS2jE34YVSzMPK2NAjAkz Q70av6r+mMTYQgBfL8p+vZHHHBNPqnmbjPyur4wWUIEtsEEKqsvxrIrWgFvAuWu2YSMz L5fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bgaXePCa; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id x24-20020a05600c179800b0040c23709c55si6885183wmo.39.2023.12.24.20.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 20:45:56 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bgaXePCa; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 44390877DA; Mon, 25 Dec 2023 05:45:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bgaXePCa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 191E3877FC; Mon, 25 Dec 2023 05:45:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DC01A877DA for ; Mon, 25 Dec 2023 05:45:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d408d0bb87so24809495ad.0 for ; Sun, 24 Dec 2023 20:45:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703479542; x=1704084342; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OOtwZXIJ0EGfMVXsfrD6wt75lYzzN7mvK9tS/JxaOqY=; b=bgaXePCaB44BFno8Q3aAEIep9Me+SkgALeMbJNTup4xiKbJsj79GE394ZsYIE7aa5k Lhqcd9hBY2Wxgy6srcr60ULUB5T+PoK3TiLRgWxvhN9DIrXfFsYoNyU4HjeVdcdlJpQK dfz4O3QamJizDPdjv9FATVixcAegPlWAnHeZA63znxMtFi4SpQevo6jagBX0QwUqvv8G BneSuGJ8Ms9RNTs4bpd7qmEPvlysCk8IwuzjMFX7OT0SJzsMX0STbdnxtBa7j5WFh6k0 sB9Qlt1zngLo6Ij+geYVYPxwFjUhXs3klNHykhBCEZKM8aXJWoKHbkHcrgumS454F08n F+iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703479542; x=1704084342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OOtwZXIJ0EGfMVXsfrD6wt75lYzzN7mvK9tS/JxaOqY=; b=ZAmPhN8x9Yz9s3VrZQCG6Y71DDL3H1aURG7yZrAor9+75zIuze5KtMqc3UH9sx1jdu KErmekr8fumF3wX7xMKfp7SQeG8DKVya0bBoXnaFMTtvjeBJsc0mg2BecSbf8Ievk4lv z3qYEOnP3N0i8gccTZG/6sZOi0+985+INeT9jxBuMsAdJ1k95BkcYv7IxJb03jVhw88I mInvxpqbJ7ohyO+Tb1vnJHt4ufH7Y8o8XONbuZ7+LIMKgdr6BSR1XfIErFeyoWTJanxO Aa07o4QQ4CO/E9EThpAF9vzE4k96XEefIVmgLO60wtG43GpBfeLO/ea3ZJIjhzYMe1bu wEzA== X-Gm-Message-State: AOJu0Yx7h0GFO5JNvYJQxjc6XdzT9cgL3XYds94/UVXHTJOaE2LXc1XV sN0NSmK3heeeeuNkd3yAI/aq01dpH86m0V0T2AL0WtRtDGA= X-Received: by 2002:a17:902:ce85:b0:1d3:b3b7:5db0 with SMTP id f5-20020a170902ce8500b001d3b3b75db0mr6851253plg.4.1703479542408; Sun, 24 Dec 2023 20:45:42 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id z3-20020a170902ee0300b001d3e3a86dccsm7285018plb.84.2023.12.24.20.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 20:45:41 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Masahisa Kojima Subject: [PATCH 1/3] efi_loader: remove unused members from struct efi_disk_obj Date: Mon, 25 Dec 2023 13:43:54 +0900 Message-Id: <20231225044356.626900-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231225044356.626900-1-masahisa.kojima@linaro.org> References: <20231225044356.626900-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean part and dev_index in struct efi_disk_obj are not used, let's remove it. This commit also removes the invalid structure comment for @dev, it does not exist. Signed-off-by: Masahisa Kojima Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_disk.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index f0d76113b0..a2f8b531a3 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -32,20 +32,15 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID; * * @header: EFI object header * @ops: EFI disk I/O protocol interface - * @dev_index: device index of block device * @media: block I/O media information * @dp: device path to the block device - * @part: partition * @volume: simple file system protocol of the partition - * @dev: associated DM device */ struct efi_disk_obj { struct efi_object header; struct efi_block_io ops; - int dev_index; struct efi_block_io_media media; struct efi_device_path *dp; - unsigned int part; struct efi_simple_file_system_protocol *volume; }; @@ -383,7 +378,6 @@ static int efi_fs_exists(struct blk_desc *desc, int part) * @parent: parent handle * @dp_parent: parent device path * @desc: internal block device - * @dev_index: device index for block device * @part_info: partition info * @part: partition * @disk: pointer to receive the created handle @@ -394,7 +388,6 @@ static efi_status_t efi_disk_add_dev( efi_handle_t parent, struct efi_device_path *dp_parent, struct blk_desc *desc, - int dev_index, struct disk_partition *part_info, unsigned int part, struct efi_disk_obj **disk, @@ -456,7 +449,6 @@ static efi_status_t efi_disk_add_dev( diskobj->dp = efi_dp_from_part(desc, part); diskobj->media.last_block = desc->lba - 1; } - diskobj->part = part; /* * Install the device path and the block IO protocol. @@ -499,7 +491,6 @@ static efi_status_t efi_disk_add_dev( goto error; } diskobj->ops = block_io_disk_template; - diskobj->dev_index = dev_index; /* Fill in EFI IO Media info (for read/write callbacks) */ diskobj->media.removable_media = desc->removable; @@ -519,7 +510,7 @@ static efi_status_t efi_disk_add_dev( EFI_PRINT("BlockIO: part %u, present %d, logical %d, removable %d" ", last_block %llu\n", - diskobj->part, + part, diskobj->media.media_present, diskobj->media.logical_partition, diskobj->media.removable_media, @@ -566,7 +557,7 @@ static int efi_disk_create_raw(struct udevice *dev, efi_handle_t agent_handle) diskid = desc->devnum; ret = efi_disk_add_dev(NULL, NULL, desc, - diskid, NULL, 0, &disk, agent_handle); + NULL, 0, &disk, agent_handle); if (ret != EFI_SUCCESS) { if (ret == EFI_NOT_READY) { log_notice("Disk %s not ready\n", dev->name); @@ -627,7 +618,7 @@ static int efi_disk_create_part(struct udevice *dev, efi_handle_t agent_handle) return -1; dp_parent = (struct efi_device_path *)handler->protocol_interface; - ret = efi_disk_add_dev(parent, dp_parent, desc, diskid, + ret = efi_disk_add_dev(parent, dp_parent, desc, info, part, &disk, agent_handle); if (ret != EFI_SUCCESS) { log_err("Adding partition for %s failed\n", dev->name); From patchwork Mon Dec 25 04:43:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 758216 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp2527678wrw; Sun, 24 Dec 2023 20:46:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpmpmTizgX3S699VkEiUGpBhbGe0Ds6X3MZD/GBnWRxUoja2cpIkJTxDt8Xq8QwEQT5hf2 X-Received: by 2002:a05:600c:5488:b0:40d:55d2:c177 with SMTP id iv8-20020a05600c548800b0040d55d2c177mr706089wmb.90.1703479567855; Sun, 24 Dec 2023 20:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703479567; cv=none; d=google.com; s=arc-20160816; b=bZLehx+yIX2mZ1J6769Szl8NBS7CK3rC4vvQbu2+uMH1D+kSIgUkOZYdlbH8xaHGT2 kgyxRGaOFnL1tny4JLoTLaP5Xn31gZiglDZTkG5EMQzuVpisW8+HKp8Te5IZmTZfVqz9 aNKuvl2ydHI1iDOD7MnTvQ3cxVOFs04EQ3s8RWfvQ9aG2/wGoivnxDEjB5rSq3tLcVS0 S8089Z1FqIgBjDf5nBh42QBNYwu/+f8+l5B/lPxVj/QZvlFEU/BKteJpjKiwutj8ukQT weSQPbP3rVK4BAb+avrz50T4t9K8uXyl5HaTcF3MjsdvCkxbBoDiXt6oibVkiyJ+Cp22 zefA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b0/Y7/jGSTjjDx7KgsviVofBq3DjOreBKBqX2VLJA1I=; fh=XwOfspvhog7otCudZV1ecvxibH3YToEgjgP70JntENo=; b=esPJBLWAChMj6QGPMUrH59ttCY56liuSyo5jaPSUyec4hZfprpkdtRy6+l2Ec+SMpy andJJDD152Q9Ouy345VPJnYfgqv+82Yeq/NRDqrZsT0jlexB7SW9HEiQc1w2KbysLKSD /iAcZ+A8FQKCSFDKtHT36cZ1sILhQBZZeE4PekkTQJZbazehsn9OSeGnVvO9DR9oN0+R xGfDAtfJK3JV5x8TBgUTLaYHWgOgFVvjE3SeOkEv2tE+7NuWu6UJ4UuZxZ+6gvNucEFN jB42hWjTRHMzDVLI/GXQ9T+Yk8+PNLX6bw3BJBsYaUoL76zpY5CKC3mOrTSjetLcMbLf 8t6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IlzZI4KN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id m30-20020a05600c3b1e00b0040b3db28266si4881395wms.157.2023.12.24.20.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 20:46:07 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IlzZI4KN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A6AD3877DE; Mon, 25 Dec 2023 05:45:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="IlzZI4KN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8FAE8877F1; Mon, 25 Dec 2023 05:45:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 793B4877FD for ; Mon, 25 Dec 2023 05:45:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3bb6fc61ce7so2511944b6e.3 for ; Sun, 24 Dec 2023 20:45:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703479546; x=1704084346; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b0/Y7/jGSTjjDx7KgsviVofBq3DjOreBKBqX2VLJA1I=; b=IlzZI4KN6RQMwg6XUkc2/aecnLyrLiuzcTm2E0LBf9o522sjIH8/vW86UOVUeEUJKB CLiDbZXo86vI60fBstLYoVlLkti7YN2Fn+HRZeq4ab3C+n5kG74qUUEYw5WPsFGvPnVq 6F1qM0b/7h5L4mM0sjq96P4yXjqfXwSOW0P7xO23tWA/opz9Kk/ZjnCAywmq2Ix49yw0 fmwjHBVjTqKvvgh9511jhOaqWhz4aXc7mRpHSL2/fUcl+fK4B8aaOnF7dVS85yH0ZKj3 TlBHiA8anDZoKDMMoDmgXeyGonJaQE322wPePEV/EUvUdNr9+6y7TJMJgwY0PAt2MrwZ ezPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703479546; x=1704084346; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b0/Y7/jGSTjjDx7KgsviVofBq3DjOreBKBqX2VLJA1I=; b=IC9hAJIYofgD4BdmeqK/5oHDqemLs3t+qRIKO7otf/zr10Tg5vYxCnjm4MuJIlTt8m pa8pXWpdBD3YA/9EBsxPt472mOYP6zHsOf6F21SxY6PS6Vi5B/KJpRbiiKh36kCZ6XZx 66c5c99TqIjV9IHt2C73w609fm+VbY9qOi2JI/IqhJ7+s88R505hu5TzQ6v+qZR5XzjF zLFZM/uQBkkDpA9zdL1omylwP5r4L3+CbYEwbV4vRDK2IOv7tcm8qMBWBoRk+D8uImVd qWnW5Er5kChkAwU1nnCvMokohXy0lLcPSgdFWkj+UG8r95IqY/989pw7a4ojwxsrtZ1k 5lyQ== X-Gm-Message-State: AOJu0YyU7wH0IRA92EbI2u2VT7QnQu1ju2it9z3j8LyHXn1zf2LA0jhq Ds5ZFJZRopqWNmQ5eZwsbK3NYUXV72Z86hxIZXBEGV74jXQ= X-Received: by 2002:a05:6808:3097:b0:3bb:634f:66ed with SMTP id bl23-20020a056808309700b003bb634f66edmr4836396oib.11.1703479546378; Sun, 24 Dec 2023 20:45:46 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id f30-20020aa79d9e000000b006d9ae6fe867sm2272875pfq.110.2023.12.24.20.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 20:45:45 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Masahisa Kojima Subject: [PATCH 2/3] efi_loader: avoid pointer access after calling efi_delete_handle Date: Mon, 25 Dec 2023 13:43:55 +0900 Message-Id: <20231225044356.626900-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231225044356.626900-1-masahisa.kojima@linaro.org> References: <20231225044356.626900-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean efi_delete_handle() calls efi_purge_handle(), then it finally frees the efi handle. Both diskobj and handle variables in efi_disk_remove() have the same pointer, we can not access diskobj->dp after calling efi_delete_handle(). This commit saves the struct efi_device_path pointer before calling efi_delete_handle(). This commit also fixes the missing free for volume member in struct efi_disk_obj. Signed-off-by: Masahisa Kojima --- lib/efi_loader/efi_disk.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index a2f8b531a3..415d8601ba 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -701,7 +701,9 @@ int efi_disk_remove(void *ctx, struct event *event) struct udevice *dev = event->data.dm.dev; efi_handle_t handle; struct blk_desc *desc; + struct efi_device_path *dp = NULL; struct efi_disk_obj *diskobj = NULL; + struct efi_simple_file_system_protocol *volume = NULL; efi_status_t ret; if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle)) @@ -722,14 +724,18 @@ int efi_disk_remove(void *ctx, struct event *event) return 0; } + if (diskobj) { + dp = diskobj->dp; + volume = diskobj->volume; + } + ret = efi_delete_handle(handle); /* Do not delete DM device if there are still EFI drivers attached. */ if (ret != EFI_SUCCESS) return -1; - if (diskobj) - efi_free_pool(diskobj->dp); - + efi_free_pool(dp); + free(volume); dev_tag_del(dev, DM_TAG_EFI); return 0; From patchwork Mon Dec 25 04:43:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 758217 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp2527716wrw; Sun, 24 Dec 2023 20:46:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IExrKMwHqWBqY+61MTwMYtXQOJdrPt9cbqYC75e82cBxs6yIH1zSwqJ3GQTM7FdC5CtDDNX X-Received: by 2002:a05:600c:1d14:b0:40c:6e99:8e6e with SMTP id l20-20020a05600c1d1400b0040c6e998e6emr1719577wms.54.1703479578746; Sun, 24 Dec 2023 20:46:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703479578; cv=none; d=google.com; s=arc-20160816; b=YYZbwOEQamaWRMlPk9i+7ANKPKgB35Vjju1453WYkGWf56+Fw1dZPVUPhEWLhnu3in 0CK45Q0Z/h9D6Nwof5NwzskV4rXiy3LpMKoPPRbVycOHK3vyInPeSbRBoISKcmHe34kN 9RwCMpfSKn/trDgg3iPAgmw/tbkjarLah7XAMqt0CzDy6q6+TDyUbeFvoBPXy7xDG2LV TPy1JHYwg98gs8u6HoVBzaOnrBVKK03IHseFcTMwgbiFSbqoCDNfQWKHGlppI6R3+rB2 XN+pwaS+9OW0xRZXuIZjyWmV5Tr+E/+HFEfNzDdJCvfGIe0Cgsr7pd7clCIsNEwooGvp gE8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iJ8+802lOUUV9adqdfjlz8ZWJmZz4bZ67ej717zYlRA=; fh=XwOfspvhog7otCudZV1ecvxibH3YToEgjgP70JntENo=; b=OB6lBPAxjoBD9pXERAkmAZVcThFCtrOHzpX9/uCnVpw6QhhIKvUHhRJLhxvFr02qpK DwccW6/IGS2nGUjs9296at/WE5KXfBtJ860ni2d9JpPfWv/Y0PlJcmbxe/H4e6yAe+hX Zea+Rc+JHDaM76ODOM4p5Q3FHAVB7kYAbUVwU/+FA+ZPwxvJdXOz9Unml7bBb9IZnFx3 +5x6bfvzAZMf14mU0cmpFV+scFSx9t2ugWp8a4Q6i4TPCS+AvjiCmD2baxhpS7d3Vkg1 skzTd9yAVFij2gpDR+UBvZziXToo+/iUE+MJ7IH//xfWEUo4sZM/hflgGHeLyWbI6nvv ib8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gGv4Lt5d; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id m2-20020a05600c3b0200b0040b3726652csi2390762wms.174.2023.12.24.20.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 20:46:18 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gGv4Lt5d; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1661987807; Mon, 25 Dec 2023 05:45:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gGv4Lt5d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA221871DA; Mon, 25 Dec 2023 05:45:55 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CFA2B87805 for ; Mon, 25 Dec 2023 05:45:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-59496704246so125523eaf.2 for ; Sun, 24 Dec 2023 20:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703479551; x=1704084351; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iJ8+802lOUUV9adqdfjlz8ZWJmZz4bZ67ej717zYlRA=; b=gGv4Lt5dp/ZPotCwSoEY57iyHgX4XInvxGmki0TDFk4cOd9QfqO5OpR+J5rJBDWwll MH7LYxujbdmA0tijPsXguwEQdH4E2aBW7Ya55tHXwvVbmwH8nVBqUVXEXkv/bF0NiJU7 KeShGmwqi1ezZkBoWBwp+MbuLkhx3rIHs4IC/u1aZroWLKsbCXORHVW4p0ZeaP/V8MBJ PmETPo87duc2jvMlwUAZzeZuf3ef1N+qtmmpdCOF9geTLvJ7MidgxpwK4PbZqtVlyyTw uSStFiG4fYCN2j/R5vpEcf0yDz+u0XLaiGOs7vTOl3VdwWNStYGrhahrbA5huBiGwWI8 /Yaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703479551; x=1704084351; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iJ8+802lOUUV9adqdfjlz8ZWJmZz4bZ67ej717zYlRA=; b=e7pAWxXzkCeaSk/jO3XLOwEwg/dirmKX+P1LpPRkOwJad8iGyn0/H0wQs9KqOI58xS 6UD2dUUdDbdhUpOhhYqFDzK4f/Vj+UK5s86w1xWztiM3vX/YZKpevEJgD1N4FGLRsK/g lqrOLRxEsoaiy44NRji8a/RkwSqAKhio5E/W9YQwepozURDcrq7l18Q9vSzcilSUErcm KFtjp87vXb1dZLsldXIQE4VxmTPb3f9jtOk5H6HgKq1dCPumd1fCLPYR6K3WS0rQTwIs hAjtKaGSw4NUiAJD82YQdd8vVK5ipHtKtzdIx7PYATUlxMFa9X2XdS6UOqOlB3ILrB3F NvQw== X-Gm-Message-State: AOJu0Yz57O83m/XOq7NBGGluucYeZb+DEwPO8SMsDMmwSV9RCAuK3JKv sODHTE+vE3/unRRZKRjSKUQOtlI9Ts720ldePK/l+Ag16v8= X-Received: by 2002:a05:6358:716:b0:174:f219:c9ec with SMTP id e22-20020a056358071600b00174f219c9ecmr300014rwj.13.1703479550779; Sun, 24 Dec 2023 20:45:50 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id sm18-20020a17090b2e5200b002868abc0e6dsm11672987pjb.11.2023.12.24.20.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 20:45:50 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Masahisa Kojima Subject: [PATCH 3/3] efi_loader: create common function to free struct efi_disk_obj Date: Mon, 25 Dec 2023 13:43:56 +0900 Message-Id: <20231225044356.626900-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231225044356.626900-1-masahisa.kojima@linaro.org> References: <20231225044356.626900-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Current error handling of creating raw disk/partition has following issues. - duplicate free for efi handle, efi handle is already freed in efi_delete_handle() - missing free for struct efi_device_path and struct efi_simple_file_system_protocol in some error paths To address those issue, this commit creates the common function to free the struct efi_disk_obj resources and calls it in case of error. Signed-off-by: Masahisa Kojima --- lib/efi_loader/efi_disk.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 415d8601ba..d2ac2fab9b 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -372,6 +372,19 @@ static int efi_fs_exists(struct blk_desc *desc, int part) return 1; } +static void efi_disk_free_diskobj(struct efi_disk_obj *diskobj) +{ + struct efi_device_path *dp = NULL; + struct efi_simple_file_system_protocol *volume = NULL; + + dp = diskobj->dp; + volume = diskobj->volume; + + efi_delete_handle(&diskobj->header); + efi_free_pool(dp); + free(volume); +} + /** * efi_disk_add_dev() - create a handle for a partition or disk * @@ -529,9 +542,7 @@ static efi_status_t efi_disk_add_dev( } return EFI_SUCCESS; error: - efi_delete_handle(&diskobj->header); - free(diskobj->volume); - free(diskobj); + efi_disk_free_diskobj(diskobj); return ret; } @@ -570,8 +581,7 @@ static int efi_disk_create_raw(struct udevice *dev, efi_handle_t agent_handle) return ret; } if (efi_link_dev(&disk->header, dev)) { - efi_free_pool(disk->dp); - efi_delete_handle(&disk->header); + efi_disk_free_diskobj(disk); return -EINVAL; } @@ -625,8 +635,7 @@ static int efi_disk_create_part(struct udevice *dev, efi_handle_t agent_handle) return -1; } if (efi_link_dev(&disk->header, dev)) { - efi_free_pool(disk->dp); - efi_delete_handle(&disk->header); + efi_disk_free_diskobj(disk); return -1; }