linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] md: Fix failed allocation of md_register_thread
@ 2019-03-04 22:48 Aditya Pakki
  2019-03-06 16:58 ` Song Liu
  2019-03-08  3:12 ` Guoqing Jiang
  0 siblings, 2 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-03-04 22:48 UTC (permalink / raw)
  To: pakki001; +Cc: kjlu, Shaohua Li, linux-raid, linux-kernel

mddev->sync_thread can be set to NULL on kzalloc failure downstream.
The patch checks for such a scenario and frees allocated resources.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/md/raid10.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index abb5d382f64d..f52b4d9bcd24 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3939,6 +3939,8 @@ static int raid10_run(struct mddev *mddev)
 		set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
 		mddev->sync_thread = md_register_thread(md_do_sync, mddev,
 							"reshape");
+		if (!mddev->sync_thread)
+			goto out_free_conf;
 	}
 
 	return 0;
-- 
2.17.1


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

* Re: [PATCH] md: Fix failed allocation of md_register_thread
  2019-03-04 22:48 [PATCH] md: Fix failed allocation of md_register_thread Aditya Pakki
@ 2019-03-06 16:58 ` Song Liu
  2019-03-08  3:12 ` Guoqing Jiang
  1 sibling, 0 replies; 4+ messages in thread
From: Song Liu @ 2019-03-06 16:58 UTC (permalink / raw)
  To: Aditya Pakki; +Cc: kjlu, Shaohua Li, linux-raid, open list

On Mon, Mar 4, 2019 at 2:50 PM Aditya Pakki <pakki001@umn.edu> wrote:
>
> mddev->sync_thread can be set to NULL on kzalloc failure downstream.
> The patch checks for such a scenario and frees allocated resources.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>

This looks good. Could you please add a "Fixed:" tag?

Thanks,
Song

> ---
>  drivers/md/raid10.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index abb5d382f64d..f52b4d9bcd24 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -3939,6 +3939,8 @@ static int raid10_run(struct mddev *mddev)
>                 set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
>                 mddev->sync_thread = md_register_thread(md_do_sync, mddev,
>                                                         "reshape");
> +               if (!mddev->sync_thread)
> +                       goto out_free_conf;
>         }
>
>         return 0;
> --
> 2.17.1
>

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

* Re: [PATCH] md: Fix failed allocation of md_register_thread
  2019-03-04 22:48 [PATCH] md: Fix failed allocation of md_register_thread Aditya Pakki
  2019-03-06 16:58 ` Song Liu
@ 2019-03-08  3:12 ` Guoqing Jiang
  2019-03-12 17:22   ` Song Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Guoqing Jiang @ 2019-03-08  3:12 UTC (permalink / raw)
  To: Aditya Pakki; +Cc: kjlu, Shaohua Li, linux-raid, linux-kernel



On 3/5/19 6:48 AM, Aditya Pakki wrote:
> mddev->sync_thread can be set to NULL on kzalloc failure downstream.
> The patch checks for such a scenario and frees allocated resources.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>   drivers/md/raid10.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index abb5d382f64d..f52b4d9bcd24 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -3939,6 +3939,8 @@ static int raid10_run(struct mddev *mddev)
>   		set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
>   		mddev->sync_thread = md_register_thread(md_do_sync, mddev,
>   							"reshape");
> +		if (!mddev->sync_thread)
> +			goto out_free_conf;
>   	}
>   
>   	return 0;

Could you make the change for raid5 as well? It also doesn't check the 
failure
in raid5_run.

Thanks,
Guoqing

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

* Re: [PATCH] md: Fix failed allocation of md_register_thread
  2019-03-08  3:12 ` Guoqing Jiang
@ 2019-03-12 17:22   ` Song Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Song Liu @ 2019-03-12 17:22 UTC (permalink / raw)
  To: Guoqing Jiang; +Cc: Aditya Pakki, kjlu, Shaohua Li, linux-raid, open list

On Thu, Mar 7, 2019 at 7:13 PM Guoqing Jiang <gqjiang@suse.com> wrote:
>
>
>
> On 3/5/19 6:48 AM, Aditya Pakki wrote:
> > mddev->sync_thread can be set to NULL on kzalloc failure downstream.
> > The patch checks for such a scenario and frees allocated resources.
> >
> > Signed-off-by: Aditya Pakki <pakki001@umn.edu>

Applied to https://github.com/liu-song-6/linux/tree/for-5.1/md-post

@Guoqing, I added your Acked-by to the commit and also the raid5 fix.

Thanks,
Song

> > ---
> >   drivers/md/raid10.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> > index abb5d382f64d..f52b4d9bcd24 100644
> > --- a/drivers/md/raid10.c
> > +++ b/drivers/md/raid10.c
> > @@ -3939,6 +3939,8 @@ static int raid10_run(struct mddev *mddev)
> >               set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
> >               mddev->sync_thread = md_register_thread(md_do_sync, mddev,
> >                                                       "reshape");
> > +             if (!mddev->sync_thread)
> > +                     goto out_free_conf;
> >       }
> >
> >       return 0;
>
> Could you make the change for raid5 as well? It also doesn't check the
> failure
> in raid5_run.
>
> Thanks,
> Guoqing

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

end of thread, other threads:[~2019-03-12 17:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-04 22:48 [PATCH] md: Fix failed allocation of md_register_thread Aditya Pakki
2019-03-06 16:58 ` Song Liu
2019-03-08  3:12 ` Guoqing Jiang
2019-03-12 17:22   ` Song Liu

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).