Linux ACPI
 help / color / mirror / Atom feed
From: Zhouyang Jia <jiazhouyang09@gmail.com>
Cc: Zhouyang Jia <jiazhouyang09@gmail.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ACPI : dock: add error handling for acpi_bus_get_device
Date: Tue, 12 Jun 2018 12:38:12 +0800	[thread overview]
Message-ID: <1528778292-41332-1-git-send-email-jiazhouyang09@gmail.com> (raw)

When acpi_bus_get_device fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling acpi_bus_get_device.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 drivers/acpi/dock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index e3fc1f0..02fc134 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -504,7 +504,9 @@ static ssize_t show_docked(struct device *dev,
 	struct dock_station *dock_station = dev->platform_data;
 	struct acpi_device *adev = NULL;
 
-	acpi_bus_get_device(dock_station->handle, &adev);
+	if (acpi_bus_get_device(dock_station->handle, &adev))
+		return -ENODEV;
+
 	return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
 }
 static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
-- 
2.7.4

             reply	other threads:[~2018-06-12  4:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12  4:38 Zhouyang Jia [this message]
2018-06-14  7:54 ` [PATCH] ACPI : dock: add error handling for acpi_bus_get_device 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=1528778292-41332-1-git-send-email-jiazhouyang09@gmail.com \
    --to=jiazhouyang09@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox