Linux kernel staging patches
 help / color / mirror / Atom feed
From: Yi Yang <yiyang13@huawei.com>
To: <vaibhav.sr@gmail.com>, <mgreer@animalcreek.com>,
	<johan@kernel.org>, <elder@kernel.org>,
	<gregkh@linuxfoundation.org>, <ankov_svetlin@projectara.com>
Cc: <greybus-dev@lists.linaro.org>, <linux-staging@lists.linux.dev>,
	<wangweiyang2@huawei.com>
Subject: [PATCH] staging: greybus: fix possible null-ptr-deref in gb_audio_manager_get_module()
Date: Sat, 26 Oct 2024 08:11:53 +0000	[thread overview]
Message-ID: <20241026081153.2649890-1-yiyang13@huawei.com> (raw)

The gb_audio_manager_get_module() is EXPORT_SYMBOL, and will return NULL
when incoming parameter id < 0, fix possible null-ptr-deref by add check
for return value.

Fixes: 8db00736d365 ("greybus: audio: Add Audio Manager")
Signed-off-by: Yi Yang <yiyang13@huawei.com>
---
 drivers/staging/greybus/audio_manager.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/audio_manager.c b/drivers/staging/greybus/audio_manager.c
index 27ca5f796c5f..1da8804e61ca 100644
--- a/drivers/staging/greybus/audio_manager.c
+++ b/drivers/staging/greybus/audio_manager.c
@@ -111,7 +111,8 @@ struct gb_audio_manager_module *gb_audio_manager_get_module(int id)
 
 	down_read(&modules_rwsem);
 	module = gb_audio_manager_get_locked(id);
-	kobject_get(&module->kobj);
+	if (module)
+		kobject_get(&module->kobj);
 	up_read(&modules_rwsem);
 	return module;
 }
-- 
2.25.1


             reply	other threads:[~2024-10-26  8:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-26  8:11 Yi Yang [this message]
2024-10-26 10:50 ` [PATCH] staging: greybus: fix possible null-ptr-deref in gb_audio_manager_get_module() Dan Carpenter
2024-10-28 12:46   ` Alex Elder
2024-10-29  2:58     ` yiyang (D)
2024-10-29 15:31       ` Alex Elder
2024-10-29 15:36         ` Dan Carpenter

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=20241026081153.2649890-1-yiyang13@huawei.com \
    --to=yiyang13@huawei.com \
    --cc=ankov_svetlin@projectara.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mgreer@animalcreek.com \
    --cc=vaibhav.sr@gmail.com \
    --cc=wangweiyang2@huawei.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