* [PATCH] dm: change dm_get_target_type() to check for module load error
@ 2021-10-04 20:06 ` Shuah Khan
0 siblings, 0 replies; 6+ messages in thread
From: Shuah Khan @ 2021-10-04 20:06 UTC (permalink / raw)
To: agk, snitzer; +Cc: Shuah Khan, dm-devel, linux-kernel
dm_get_target_type() doesn't check error return from request_module().
Change to check for error and return NULL instead of trying to get
target type again which would fail.
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
drivers/md/dm-target.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index 64dd0b34fcf4..0789e9f91d3a 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -41,17 +41,22 @@ static struct target_type *get_target_type(const char *name)
return tt;
}
-static void load_module(const char *name)
+static int load_module(const char *name)
{
- request_module("dm-%s", name);
+ return request_module("dm-%s", name);
}
struct target_type *dm_get_target_type(const char *name)
{
struct target_type *tt = get_target_type(name);
+ int ret;
if (!tt) {
- load_module(name);
+ ret = load_module(name);
+ if (ret < 0) {
+ pr_err("Module %s load failed %d\n", name, ret);
+ return NULL;
+ }
tt = get_target_type(name);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [dm-devel] [PATCH] dm: change dm_get_target_type() to check for module load error
@ 2021-10-04 20:06 ` Shuah Khan
0 siblings, 0 replies; 6+ messages in thread
From: Shuah Khan @ 2021-10-04 20:06 UTC (permalink / raw)
To: agk, snitzer; +Cc: dm-devel, linux-kernel, Shuah Khan
dm_get_target_type() doesn't check error return from request_module().
Change to check for error and return NULL instead of trying to get
target type again which would fail.
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
drivers/md/dm-target.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index 64dd0b34fcf4..0789e9f91d3a 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -41,17 +41,22 @@ static struct target_type *get_target_type(const char *name)
return tt;
}
-static void load_module(const char *name)
+static int load_module(const char *name)
{
- request_module("dm-%s", name);
+ return request_module("dm-%s", name);
}
struct target_type *dm_get_target_type(const char *name)
{
struct target_type *tt = get_target_type(name);
+ int ret;
if (!tt) {
- load_module(name);
+ ret = load_module(name);
+ if (ret < 0) {
+ pr_err("Module %s load failed %d\n", name, ret);
+ return NULL;
+ }
tt = get_target_type(name);
}
--
2.30.2
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: dm: change dm_get_target_type() to check for module load error
2021-10-04 20:06 ` [dm-devel] " Shuah Khan
@ 2021-10-06 20:35 ` Mike Snitzer
-1 siblings, 0 replies; 6+ messages in thread
From: Mike Snitzer @ 2021-10-06 20:35 UTC (permalink / raw)
To: Shuah Khan; +Cc: agk, dm-devel, linux-kernel
On Mon, Oct 04 2021 at 4:06P -0400,
Shuah Khan <skhan@linuxfoundation.org> wrote:
> dm_get_target_type() doesn't check error return from request_module().
> Change to check for error and return NULL instead of trying to get
> target type again which would fail.
>
> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
> ---
> drivers/md/dm-target.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
> index 64dd0b34fcf4..0789e9f91d3a 100644
> --- a/drivers/md/dm-target.c
> +++ b/drivers/md/dm-target.c
> @@ -41,17 +41,22 @@ static struct target_type *get_target_type(const char *name)
> return tt;
> }
>
> -static void load_module(const char *name)
> +static int load_module(const char *name)
> {
> - request_module("dm-%s", name);
> + return request_module("dm-%s", name);
> }
>
> struct target_type *dm_get_target_type(const char *name)
> {
> struct target_type *tt = get_target_type(name);
> + int ret;
>
> if (!tt) {
> - load_module(name);
> + ret = load_module(name);
> + if (ret < 0) {
> + pr_err("Module %s load failed %d\n", name, ret);
> + return NULL;
> + }
> tt = get_target_type(name);
> }
>
> --
> 2.30.2
>
While I appreciate your intent, the reality is that multiple targets
may be made available in a given module. And so loading one dm module
may bring in access to N targets. There isn't a rigid 1:1 mapping of
target modules to names. And there may not even be a loadable module
that has the name dm-${name} -- but that doesn't mean the target_type
won;t have been loaded into DM for it to access.
So all said, your patch is bogus and would break DM and user
experience:
Nacked-by: Mike Snitzer <snitzer@redhat.com>
But thanks for raising your concern.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dm-devel] dm: change dm_get_target_type() to check for module load error
@ 2021-10-06 20:35 ` Mike Snitzer
0 siblings, 0 replies; 6+ messages in thread
From: Mike Snitzer @ 2021-10-06 20:35 UTC (permalink / raw)
To: Shuah Khan; +Cc: dm-devel, linux-kernel, agk
On Mon, Oct 04 2021 at 4:06P -0400,
Shuah Khan <skhan@linuxfoundation.org> wrote:
> dm_get_target_type() doesn't check error return from request_module().
> Change to check for error and return NULL instead of trying to get
> target type again which would fail.
>
> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
> ---
> drivers/md/dm-target.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
> index 64dd0b34fcf4..0789e9f91d3a 100644
> --- a/drivers/md/dm-target.c
> +++ b/drivers/md/dm-target.c
> @@ -41,17 +41,22 @@ static struct target_type *get_target_type(const char *name)
> return tt;
> }
>
> -static void load_module(const char *name)
> +static int load_module(const char *name)
> {
> - request_module("dm-%s", name);
> + return request_module("dm-%s", name);
> }
>
> struct target_type *dm_get_target_type(const char *name)
> {
> struct target_type *tt = get_target_type(name);
> + int ret;
>
> if (!tt) {
> - load_module(name);
> + ret = load_module(name);
> + if (ret < 0) {
> + pr_err("Module %s load failed %d\n", name, ret);
> + return NULL;
> + }
> tt = get_target_type(name);
> }
>
> --
> 2.30.2
>
While I appreciate your intent, the reality is that multiple targets
may be made available in a given module. And so loading one dm module
may bring in access to N targets. There isn't a rigid 1:1 mapping of
target modules to names. And there may not even be a loadable module
that has the name dm-${name} -- but that doesn't mean the target_type
won;t have been loaded into DM for it to access.
So all said, your patch is bogus and would break DM and user
experience:
Nacked-by: Mike Snitzer <snitzer@redhat.com>
But thanks for raising your concern.
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: dm: change dm_get_target_type() to check for module load error
2021-10-06 20:35 ` [dm-devel] " Mike Snitzer
@ 2021-10-06 20:55 ` Shuah Khan
-1 siblings, 0 replies; 6+ messages in thread
From: Shuah Khan @ 2021-10-06 20:55 UTC (permalink / raw)
To: Mike Snitzer; +Cc: agk, dm-devel, linux-kernel, Shuah Khan
On 10/6/21 2:35 PM, Mike Snitzer wrote:
> On Mon, Oct 04 2021 at 4:06P -0400,
> Shuah Khan <skhan@linuxfoundation.org> wrote:
>
>> dm_get_target_type() doesn't check error return from request_module().
>> Change to check for error and return NULL instead of trying to get
>> target type again which would fail.
>>
>> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
>> ---
>> drivers/md/dm-target.c | 11 ++++++++---
>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
>> index 64dd0b34fcf4..0789e9f91d3a 100644
>> --- a/drivers/md/dm-target.c
>> +++ b/drivers/md/dm-target.c
>> @@ -41,17 +41,22 @@ static struct target_type *get_target_type(const char *name)
>> return tt;
>> }
>>
>> -static void load_module(const char *name)
>> +static int load_module(const char *name)
>> {
>> - request_module("dm-%s", name);
>> + return request_module("dm-%s", name);
>> }
>>
>> struct target_type *dm_get_target_type(const char *name)
>> {
>> struct target_type *tt = get_target_type(name);
>> + int ret;
>>
>> if (!tt) {
>> - load_module(name);
>> + ret = load_module(name);
>> + if (ret < 0) {
>> + pr_err("Module %s load failed %d\n", name, ret);
>> + return NULL;
>> + }
>> tt = get_target_type(name);
>> }
>>
>> --
>> 2.30.2
>>
>
> While I appreciate your intent, the reality is that multiple targets
> may be made available in a given module. And so loading one dm module
> may bring in access to N targets. There isn't a rigid 1:1 mapping of
> target modules to names. And there may not even be a loadable module
> that has the name dm-${name} -- but that doesn't mean the target_type
> won;t have been loaded into DM for it to access.
>
Thanks for the explanation.
-- Shuah
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dm-devel] dm: change dm_get_target_type() to check for module load error
@ 2021-10-06 20:55 ` Shuah Khan
0 siblings, 0 replies; 6+ messages in thread
From: Shuah Khan @ 2021-10-06 20:55 UTC (permalink / raw)
To: Mike Snitzer; +Cc: dm-devel, linux-kernel, agk, Shuah Khan
On 10/6/21 2:35 PM, Mike Snitzer wrote:
> On Mon, Oct 04 2021 at 4:06P -0400,
> Shuah Khan <skhan@linuxfoundation.org> wrote:
>
>> dm_get_target_type() doesn't check error return from request_module().
>> Change to check for error and return NULL instead of trying to get
>> target type again which would fail.
>>
>> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
>> ---
>> drivers/md/dm-target.c | 11 ++++++++---
>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
>> index 64dd0b34fcf4..0789e9f91d3a 100644
>> --- a/drivers/md/dm-target.c
>> +++ b/drivers/md/dm-target.c
>> @@ -41,17 +41,22 @@ static struct target_type *get_target_type(const char *name)
>> return tt;
>> }
>>
>> -static void load_module(const char *name)
>> +static int load_module(const char *name)
>> {
>> - request_module("dm-%s", name);
>> + return request_module("dm-%s", name);
>> }
>>
>> struct target_type *dm_get_target_type(const char *name)
>> {
>> struct target_type *tt = get_target_type(name);
>> + int ret;
>>
>> if (!tt) {
>> - load_module(name);
>> + ret = load_module(name);
>> + if (ret < 0) {
>> + pr_err("Module %s load failed %d\n", name, ret);
>> + return NULL;
>> + }
>> tt = get_target_type(name);
>> }
>>
>> --
>> 2.30.2
>>
>
> While I appreciate your intent, the reality is that multiple targets
> may be made available in a given module. And so loading one dm module
> may bring in access to N targets. There isn't a rigid 1:1 mapping of
> target modules to names. And there may not even be a loadable module
> that has the name dm-${name} -- but that doesn't mean the target_type
> won;t have been loaded into DM for it to access.
>
Thanks for the explanation.
-- Shuah
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-07 8:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 20:06 [PATCH] dm: change dm_get_target_type() to check for module load error Shuah Khan
2021-10-04 20:06 ` [dm-devel] " Shuah Khan
2021-10-06 20:35 ` Mike Snitzer
2021-10-06 20:35 ` [dm-devel] " Mike Snitzer
2021-10-06 20:55 ` Shuah Khan
2021-10-06 20:55 ` [dm-devel] " Shuah Khan
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.