From: "Pali Rohár" <pali@kernel.org>
To: Michal Wilczynski <michal.wilczynski@intel.com>
Cc: linux-acpi@vger.kernel.org, rafael@kernel.org,
andriy.shevchenko@intel.com, ilpo.jarvinen@linux.intel.com,
hdegoede@redhat.com, markgross@kernel.org,
fengguang.wu@intel.com, dvhart@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] platform/x86/dell/dell-rbtn: Fix resources leaking on error path
Date: Mon, 12 Jun 2023 19:52:05 +0200 [thread overview]
Message-ID: <20230612175205.eom2guabgfmnzrce@pali> (raw)
In-Reply-To: <20230612090250.1417940-1-michal.wilczynski@intel.com>
On Monday 12 June 2023 12:02:50 Michal Wilczynski wrote:
> Currently rbtn_add() in case of failure is leaking resources. Fix this
> by adding a proper rollback. While at it, remove unnecessary assignment
> of NULL to device->driver_data and unnecessary whitespace, plus add a
> break for the default case in a switch.
>
> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Fixes: 817a5cdb40c8 ("dell-rbtn: Dell Airplane Mode Switch driver")
> Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/platform/x86/dell/dell-rbtn.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/dell-rbtn.c b/drivers/platform/x86/dell/dell-rbtn.c
> index aa0e6c907494..e9b3f9c3ab7d 100644
> --- a/drivers/platform/x86/dell/dell-rbtn.c
> +++ b/drivers/platform/x86/dell/dell-rbtn.c
> @@ -420,10 +420,12 @@ static int rbtn_add(struct acpi_device *device)
> break;
> default:
> ret = -EINVAL;
> + break;
> }
> + if (ret)
> + rbtn_acquire(device, false);
>
> return ret;
> -
> }
Hello! I'm looking at rbtn_add() function and there is also code:
rbtn_data = devm_kzalloc(&device->dev, sizeof(*rbtn_data), GFP_KERNEL);
if (!rbtn_data)
return -ENOMEM;
which is called after rbtn_acquire(). So it looks like when kzalloc
fails then there is another leak...
>
> static void rbtn_remove(struct acpi_device *device)
> @@ -442,7 +444,6 @@ static void rbtn_remove(struct acpi_device *device)
> }
>
> rbtn_acquire(device, false);
> - device->driver_data = NULL;
> }
>
> static void rbtn_notify(struct acpi_device *device, u32 event)
> --
> 2.40.1
>
next prev parent reply other threads:[~2023-06-12 17:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 9:02 [PATCH v1] platform/x86/dell/dell-rbtn: Fix resources leaking on error path Michal Wilczynski
2023-06-12 11:21 ` Rafael J. Wysocki
2023-06-12 17:52 ` Pali Rohár [this message]
2023-06-12 20:52 ` Andy Shevchenko
2023-06-12 20:58 ` Pali Rohár
2023-06-12 21:02 ` Andy Shevchenko
2023-06-13 9:28 ` Ilpo Järvinen
2023-06-13 9:57 ` Wilczynski, Michal
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=20230612175205.eom2guabgfmnzrce@pali \
--to=pali@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=dvhart@linux.intel.com \
--cc=fengguang.wu@intel.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=michal.wilczynski@intel.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
/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