mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wang Hai <wanghai38@huawei.com>
To: <johan@kernel.org>, <vaibhav.sr@gmail.com>
Cc: <elder@kernel.org>, <gregkh@linuxfoundation.org>,
	<dan.carpenter@oracle.com>, <aibhav.sr@gmail.com>,
	<greybus-dev@lists.linaro.org>, <devel@driverdev.osuosl.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls
Date: Sat, 5 Dec 2020 18:38:27 +0800	[thread overview]
Message-ID: <20201205103827.31244-1-wanghai38@huawei.com> (raw)

In gbaudio_dapm_free_controls(), if one of the widgets is not found, an error
will be returned directly, which will cause the rest to be unable to be freed,
resulting in leak.

This patch fixes the bug. If if one of them is not found, just skip and free the others.

Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
 drivers/staging/greybus/audio_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
index 237531ba60f3..3011b8abce38 100644
--- a/drivers/staging/greybus/audio_helper.c
+++ b/drivers/staging/greybus/audio_helper.c
@@ -135,7 +135,8 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
 		if (!w) {
 			dev_err(dapm->dev, "%s: widget not found\n",
 				widget->name);
-			return -EINVAL;
+			widget++;
+			continue;
 		}
 		widget++;
 #ifdef CONFIG_DEBUG_FS
-- 
2.17.1


             reply	other threads:[~2020-12-05 10:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-05 10:38 Wang Hai [this message]
2020-12-05 14:46 ` Vaibhav Agarwal
2020-12-08  9:35 ` Johan Hovold
     [not found]   ` <ed57715b-c524-4726-3eaf-434af96d2d92@huawei.com>
2020-12-14  9:48     ` Johan Hovold

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=20201205103827.31244-1-wanghai38@huawei.com \
    --to=wanghai38@huawei.com \
    --cc=aibhav.sr@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vaibhav.sr@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®