* [PATCH 5.10] media: ti: cal: revert "media: ti: cal: fix possible memory leak in cal_ctx_create()"
@ 2023-04-03 12:17 Gaosheng Cui
2023-04-03 12:53 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Gaosheng Cui @ 2023-04-03 12:17 UTC (permalink / raw)
To: stable, cuigaosheng1
Cc: bparrot, mchehab, sashal, laurent.pinchart, gregkh, patches
This reverts commit c7a218cbf67fffcd99b76ae3b5e9c2e8bef17c8c.
The memory of ctx is allocated by devm_kzalloc in cal_ctx_create,
it should not be freed by kfree when cal_ctx_v4l2_init() fails,
otherwise kfree() will cause double free, so revert this patch.
Fixes: c7a218cbf67f ("media: ti: cal: fix possible memory leak in cal_ctx_create()")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
drivers/media/platform/ti-vpe/cal.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 93121c90d76a..2eef245c31a1 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -624,10 +624,8 @@ static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst)
ctx->cport = inst;
ret = cal_ctx_v4l2_init(ctx);
- if (ret) {
- kfree(ctx);
+ if (ret)
return NULL;
- }
return ctx;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 5.10] media: ti: cal: revert "media: ti: cal: fix possible memory leak in cal_ctx_create()"
2023-04-03 12:17 [PATCH 5.10] media: ti: cal: revert "media: ti: cal: fix possible memory leak in cal_ctx_create()" Gaosheng Cui
@ 2023-04-03 12:53 ` Greg KH
[not found] ` <beac5f8a-d96e-1e1f-1e3c-18f3f9d7519c@huawei.com>
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2023-04-03 12:53 UTC (permalink / raw)
To: Gaosheng Cui; +Cc: stable, bparrot, mchehab, sashal, laurent.pinchart, patches
On Mon, Apr 03, 2023 at 08:17:04PM +0800, Gaosheng Cui wrote:
> This reverts commit c7a218cbf67fffcd99b76ae3b5e9c2e8bef17c8c.
>
> The memory of ctx is allocated by devm_kzalloc in cal_ctx_create,
> it should not be freed by kfree when cal_ctx_v4l2_init() fails,
> otherwise kfree() will cause double free, so revert this patch.
>
> Fixes: c7a218cbf67f ("media: ti: cal: fix possible memory leak in cal_ctx_create()")
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
> drivers/media/platform/ti-vpe/cal.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
> index 93121c90d76a..2eef245c31a1 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -624,10 +624,8 @@ static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst)
> ctx->cport = inst;
>
> ret = cal_ctx_v4l2_init(ctx);
> - if (ret) {
> - kfree(ctx);
> + if (ret)
> return NULL;
> - }
>
> return ctx;
> }
> --
> 2.25.1
>
Why is this not needed to be reverted in Linus's tree first?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 5.10] media: ti: cal: revert "media: ti: cal: fix possible memory leak in cal_ctx_create()"
[not found] ` <beac5f8a-d96e-1e1f-1e3c-18f3f9d7519c@huawei.com>
@ 2023-04-03 13:35 ` Greg KH
2023-04-04 1:35 ` cuigaosheng
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2023-04-03 13:35 UTC (permalink / raw)
To: cuigaosheng; +Cc: stable, bparrot, mchehab, sashal, laurent.pinchart, patches
On Mon, Apr 03, 2023 at 09:11:43PM +0800, cuigaosheng wrote:
> On 2023/4/3 20:53, Greg KH wrote:
> > On Mon, Apr 03, 2023 at 08:17:04PM +0800, Gaosheng Cui wrote:
> > > This reverts commit c7a218cbf67fffcd99b76ae3b5e9c2e8bef17c8c.
> > >
> > > The memory of ctx is allocated by devm_kzalloc in cal_ctx_create,
> > > it should not be freed by kfree when cal_ctx_v4l2_init() fails,
> > > otherwise kfree() will cause double free, so revert this patch.
> > >
> > > Fixes: c7a218cbf67f ("media: ti: cal: fix possible memory leak in cal_ctx_create()")
> > > Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> > > ---
> > > drivers/media/platform/ti-vpe/cal.c | 4 +---
> > > 1 file changed, 1 insertion(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
> > > index 93121c90d76a..2eef245c31a1 100644
> > > --- a/drivers/media/platform/ti-vpe/cal.c
> > > +++ b/drivers/media/platform/ti-vpe/cal.c
> > > @@ -624,10 +624,8 @@ static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst)
> > > ctx->cport = inst;
> > > ret = cal_ctx_v4l2_init(ctx);
> > > - if (ret) {
> > > - kfree(ctx);
> > > + if (ret)
> > > return NULL;
> > > - }
> > > return ctx;
> > > }
> > > --
> > > 2.25.1
> > >
> > Why is this not needed to be reverted in Linus's tree first?
> >
> > thanks,
> >
> > greg k-h
> > .
>
> Thanks for taking time to review this patch.
>
> The memory of ctx is allocated by kzalloc since commit 9e67f24e4d90
> ("media: ti-vpe: cal: fix ctx uninitialization"), so the fixes tag
> of patch c7a218cbf67fis not entirely accurate, mainline should merge this
> patch, but it should not be merged into 5.10, my apologies for
> notdiscovering this bug earlier. Gaosheng.
>
Great, can you please put all of this information in the changelog
explaining why this is only needed for this one branch and resend it?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 5.10] media: ti: cal: revert "media: ti: cal: fix possible memory leak in cal_ctx_create()"
2023-04-03 13:35 ` Greg KH
@ 2023-04-04 1:35 ` cuigaosheng
0 siblings, 0 replies; 4+ messages in thread
From: cuigaosheng @ 2023-04-04 1:35 UTC (permalink / raw)
To: Greg KH; +Cc: stable, bparrot, mchehab, sashal, laurent.pinchart, patches
On 2023/4/3 21:35, Greg KH wrote:
> On Mon, Apr 03, 2023 at 09:11:43PM +0800, cuigaosheng wrote:
>> On 2023/4/3 20:53, Greg KH wrote:
>>> On Mon, Apr 03, 2023 at 08:17:04PM +0800, Gaosheng Cui wrote:
>>>> This reverts commit c7a218cbf67fffcd99b76ae3b5e9c2e8bef17c8c.
>>>>
>>>> The memory of ctx is allocated by devm_kzalloc in cal_ctx_create,
>>>> it should not be freed by kfree when cal_ctx_v4l2_init() fails,
>>>> otherwise kfree() will cause double free, so revert this patch.
>>>>
>>>> Fixes: c7a218cbf67f ("media: ti: cal: fix possible memory leak in cal_ctx_create()")
>>>> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
>>>> ---
>>>> drivers/media/platform/ti-vpe/cal.c | 4 +---
>>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
>>>> index 93121c90d76a..2eef245c31a1 100644
>>>> --- a/drivers/media/platform/ti-vpe/cal.c
>>>> +++ b/drivers/media/platform/ti-vpe/cal.c
>>>> @@ -624,10 +624,8 @@ static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst)
>>>> ctx->cport = inst;
>>>> ret = cal_ctx_v4l2_init(ctx);
>>>> - if (ret) {
>>>> - kfree(ctx);
>>>> + if (ret)
>>>> return NULL;
>>>> - }
>>>> return ctx;
>>>> }
>>>> --
>>>> 2.25.1
>>>>
>>> Why is this not needed to be reverted in Linus's tree first?
>>>
>>> thanks,
>>>
>>> greg k-h
>>> .
>> Thanks for taking time to review this patch.
>>
>> The memory of ctx is allocated by kzalloc since commit 9e67f24e4d90
>> ("media: ti-vpe: cal: fix ctx uninitialization"), so the fixes tag
>> of patch c7a218cbf67fis not entirely accurate, mainline should merge this
>> patch, but it should not be merged into 5.10, my apologies for
>> notdiscovering this bug earlier. Gaosheng.
>>
> Great, can you please put all of this information in the changelog
> explaining why this is only needed for this one branch and resend it?
>
> thanks,
>
> greg k-h
> .
I have updated the commit message and resend it, thanks!
Gaosheng.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-04 1:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-03 12:17 [PATCH 5.10] media: ti: cal: revert "media: ti: cal: fix possible memory leak in cal_ctx_create()" Gaosheng Cui
2023-04-03 12:53 ` Greg KH
[not found] ` <beac5f8a-d96e-1e1f-1e3c-18f3f9d7519c@huawei.com>
2023-04-03 13:35 ` Greg KH
2023-04-04 1:35 ` cuigaosheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox