* [PATCH] memstick: fix a potential NULL pointer dereference
@ 2019-03-09 7:59 Kangjie Lu
2019-03-23 3:08 ` Kangjie Lu
0 siblings, 1 reply; 3+ messages in thread
From: Kangjie Lu @ 2019-03-09 7:59 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, Maxim Levitsky, linux-kernel
In case alloc_ordered_workqueue fails, the fix returns ENOMEM to
avoid potential NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/memstick/core/ms_block.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
index 82daccc9ea62..8e00de414567 100644
--- a/drivers/memstick/core/ms_block.c
+++ b/drivers/memstick/core/ms_block.c
@@ -2149,6 +2149,11 @@ static int msb_init_disk(struct memstick_dev *card)
msb->usage_count = 1;
msb->io_queue = alloc_ordered_workqueue("ms_block", WQ_MEM_RECLAIM);
+ if (!msb->io_queue) {
+ rc = -ENOMEM;
+ goto out_put_disk;
+ }
+
INIT_WORK(&msb->io_work, msb_io_work);
sg_init_table(msb->prealloc_sg, MS_BLOCK_MAX_SEGS+1);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] memstick: fix a potential NULL pointer dereference
2019-03-09 7:59 [PATCH] memstick: fix a potential NULL pointer dereference Kangjie Lu
@ 2019-03-23 3:08 ` Kangjie Lu
2019-03-23 7:57 ` Maxim Levitsky
0 siblings, 1 reply; 3+ messages in thread
From: Kangjie Lu @ 2019-03-23 3:08 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, Maxim Levitsky, linux-kernel
Hi Maxim,
Can you review this patch?
Thanks,
> On Mar 9, 2019, at 1:59 AM, Kangjie Lu <kjlu@umn.edu> wrote:
>
> In case alloc_ordered_workqueue fails, the fix returns ENOMEM to
> avoid potential NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/memstick/core/ms_block.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
> index 82daccc9ea62..8e00de414567 100644
> --- a/drivers/memstick/core/ms_block.c
> +++ b/drivers/memstick/core/ms_block.c
> @@ -2149,6 +2149,11 @@ static int msb_init_disk(struct memstick_dev *card)
>
> msb->usage_count = 1;
> msb->io_queue = alloc_ordered_workqueue("ms_block", WQ_MEM_RECLAIM);
> + if (!msb->io_queue) {
> + rc = -ENOMEM;
> + goto out_put_disk;
> + }
> +
> INIT_WORK(&msb->io_work, msb_io_work);
> sg_init_table(msb->prealloc_sg, MS_BLOCK_MAX_SEGS+1);
>
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memstick: fix a potential NULL pointer dereference
2019-03-23 3:08 ` Kangjie Lu
@ 2019-03-23 7:57 ` Maxim Levitsky
0 siblings, 0 replies; 3+ messages in thread
From: Maxim Levitsky @ 2019-03-23 7:57 UTC (permalink / raw)
To: Kangjie Lu; +Cc: pakki001, LKML
On Sat, Mar 23, 2019 at 5:08 AM Kangjie Lu <kjlu@umn.edu> wrote:
>
> Hi Maxim,
>
> Can you review this patch?
>
> Thanks,
>
> > On Mar 9, 2019, at 1:59 AM, Kangjie Lu <kjlu@umn.edu> wrote:
> >
> > In case alloc_ordered_workqueue fails, the fix returns ENOMEM to
> > avoid potential NULL pointer dereference.
> >
> > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > ---
> > drivers/memstick/core/ms_block.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
> > index 82daccc9ea62..8e00de414567 100644
> > --- a/drivers/memstick/core/ms_block.c
> > +++ b/drivers/memstick/core/ms_block.c
> > @@ -2149,6 +2149,11 @@ static int msb_init_disk(struct memstick_dev *card)
> >
> > msb->usage_count = 1;
> > msb->io_queue = alloc_ordered_workqueue("ms_block", WQ_MEM_RECLAIM);
> > + if (!msb->io_queue) {
> > + rc = -ENOMEM;
> > + goto out_put_disk;
> > + }
> > +
> > INIT_WORK(&msb->io_work, msb_io_work);
> > sg_init_table(msb->prealloc_sg, MS_BLOCK_MAX_SEGS+1);
> >
> > --
> > 2.17.1
> >
Looks OK to me!
Reviewed-by: Maxim Levitsky <maximlevitsky@gmail.com>
Best regards,
Maxim Levitsky
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-23 7:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-09 7:59 [PATCH] memstick: fix a potential NULL pointer dereference Kangjie Lu
2019-03-23 3:08 ` Kangjie Lu
2019-03-23 7:57 ` Maxim Levitsky
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).