linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fsi: core: Check error number after calling ida_simple_get
@ 2022-01-11  7:34 Jiasheng Jiang
  2022-01-11 14:51 ` Eddie James
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-01-11  7:34 UTC (permalink / raw)
  To: jk, joel, alistair, eajames; +Cc: linux-fsi, linux-kernel, Jiasheng Jiang

If allocation fails, the ida_simple_get() will return error number.
So master->idx could be error number and be used in dev_set_name().
Therefore, it should be better to check it and return error if fails,
like the ida_simple_get() in __fsi_get_new_minor().

Fixes: 09aecfab93b8 ("drivers/fsi: Add fsi master definition")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/fsi/fsi-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 59ddc9fd5bca..92e6eebd1851 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -1309,6 +1309,9 @@ int fsi_master_register(struct fsi_master *master)
 
 	mutex_init(&master->scan_lock);
 	master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL);
+	if (master->idx < 0)
+		return master->idx;
+
 	dev_set_name(&master->dev, "fsi%d", master->idx);
 	master->dev.class = &fsi_master_class;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fsi: core: Check error number after calling ida_simple_get
  2022-01-11  7:34 [PATCH] fsi: core: Check error number after calling ida_simple_get Jiasheng Jiang
@ 2022-01-11 14:51 ` Eddie James
  0 siblings, 0 replies; 2+ messages in thread
From: Eddie James @ 2022-01-11 14:51 UTC (permalink / raw)
  To: Jiasheng Jiang, jk, joel, alistair; +Cc: linux-fsi, linux-kernel


On 1/11/22 01:34, Jiasheng Jiang wrote:
> If allocation fails, the ida_simple_get() will return error number.
> So master->idx could be error number and be used in dev_set_name().
> Therefore, it should be better to check it and return error if fails,
> like the ida_simple_get() in __fsi_get_new_minor().


Reviewed-by:  Eddie James <eajames@linux.ibm.com>


>
> Fixes: 09aecfab93b8 ("drivers/fsi: Add fsi master definition")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>   drivers/fsi/fsi-core.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
> index 59ddc9fd5bca..92e6eebd1851 100644
> --- a/drivers/fsi/fsi-core.c
> +++ b/drivers/fsi/fsi-core.c
> @@ -1309,6 +1309,9 @@ int fsi_master_register(struct fsi_master *master)
>   
>   	mutex_init(&master->scan_lock);
>   	master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL);
> +	if (master->idx < 0)
> +		return master->idx;
> +
>   	dev_set_name(&master->dev, "fsi%d", master->idx);
>   	master->dev.class = &fsi_master_class;
>   

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-11 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11  7:34 [PATCH] fsi: core: Check error number after calling ida_simple_get Jiasheng Jiang
2022-01-11 14:51 ` Eddie James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).