All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
To: robert.moore@intel.com, rafael.j.wysocki@intel.com, lenb@kernel.org
Cc: linux-acpi@vger.kernel.org, devel@acpica.org,
	linux-kernel@vger.kernel.org,
	Jiasheng Jiang <jiasheng@iscas.ac.cn>
Subject: [PATCH] ACPI/ACPICA: Check for NULL pointer after calling alloc
Date: Fri, 14 Jan 2022 18:15:46 +0800	[thread overview]
Message-ID: <20220114101546.1368163-1-jiasheng@iscas.ac.cn> (raw)

As the possible failure of the allocation, object_info could be NULL
pointer.
Therefore, it should be better to check it in order to avoid the
dereference of the NULL pointer.
If fails, we should return 'AE_NON_MEMORY' and the caller
acpi_db_command_dispatch() will deal with the return status of
acpi_db_display_objects().
Also, the comment of the acpi_db_display_objects() is wrong.
So we need to correct it too.

Fixes: 995751025572 ("ACPICA: Linuxize: Export debugger files to Linux")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/acpi/acpica/dbnames.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
index 3615e1a6efd8..d8e5852fadb1 100644
--- a/drivers/acpi/acpica/dbnames.c
+++ b/drivers/acpi/acpica/dbnames.c
@@ -632,7 +632,7 @@ acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
  * PARAMETERS:  obj_type_arg        - Type of object to display
  *              display_count_arg   - Max depth to display
  *
- * RETURN:      None
+ * RETURN:      Status
  *
  * DESCRIPTION: Display objects in the namespace of the requested type
  *
@@ -651,6 +651,8 @@ acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
 	if (!obj_type_arg) {
 		object_info =
 		    ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
+		if (!object_info)
+			return (AE_NO_MEMORY);
 
 		/* Walk the namespace from the root */
 
-- 
2.25.1


             reply	other threads:[~2022-01-14 10:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-14 10:15 Jiasheng Jiang [this message]
2022-01-14 18:09 ` [PATCH] ACPI/ACPICA: Check for NULL pointer after calling alloc Rafael J. Wysocki
2022-01-14 18:09   ` [Devel] " Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220114101546.1368163-1-jiasheng@iscas.ac.cn \
    --to=jiasheng@iscas.ac.cn \
    --cc=devel@acpica.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robert.moore@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.