* [PATCH] drm/msm/dpu: Fix usage of ERR_PTR()
@ 2020-05-28 13:08 Zenghui Yu
2020-06-20 10:26 ` Zenghui Yu
0 siblings, 1 reply; 3+ messages in thread
From: Zenghui Yu @ 2020-05-28 13:08 UTC (permalink / raw)
To: linux-arm-msm, dri-devel, freedreno, linux-kernel
Cc: robdclark, sean, airlied, daniel, jsanka, wanghaibin.wang, Zenghui Yu
ERR_PTR() is used in the kernel to encode an usual *negative* errno code
into a pointer. Passing a positive value (ENOMEM) to it will break the
following IS_ERR() check.
Though memory allocation is unlikely to fail, it's still worth fixing.
And grepping shows that this is the only misuse of ERR_PTR() in kernel.
Fixes: 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
---
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index a1b79ee2bd9d..a2f6b688a976 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -2173,7 +2173,7 @@ struct drm_encoder *dpu_encoder_init(struct drm_device *dev,
dpu_enc = devm_kzalloc(dev->dev, sizeof(*dpu_enc), GFP_KERNEL);
if (!dpu_enc)
- return ERR_PTR(ENOMEM);
+ return ERR_PTR(-ENOMEM);
rc = drm_encoder_init(dev, &dpu_enc->base, &dpu_encoder_funcs,
drm_enc_mode, NULL);
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/msm/dpu: Fix usage of ERR_PTR()
2020-05-28 13:08 [PATCH] drm/msm/dpu: Fix usage of ERR_PTR() Zenghui Yu
@ 2020-06-20 10:26 ` Zenghui Yu
2020-06-20 16:27 ` Rob Clark
0 siblings, 1 reply; 3+ messages in thread
From: Zenghui Yu @ 2020-06-20 10:26 UTC (permalink / raw)
To: linux-arm-msm, dri-devel, freedreno, linux-kernel
Cc: robdclark, sean, airlied, daniel, jsanka, wanghaibin.wang
ping for this obvious fix...
On 2020/5/28 21:08, Zenghui Yu wrote:
> ERR_PTR() is used in the kernel to encode an usual *negative* errno code
> into a pointer. Passing a positive value (ENOMEM) to it will break the
> following IS_ERR() check.
>
> Though memory allocation is unlikely to fail, it's still worth fixing.
> And grepping shows that this is the only misuse of ERR_PTR() in kernel.
>
> Fixes: 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")
> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
> ---
> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> index a1b79ee2bd9d..a2f6b688a976 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> @@ -2173,7 +2173,7 @@ struct drm_encoder *dpu_encoder_init(struct drm_device *dev,
>
> dpu_enc = devm_kzalloc(dev->dev, sizeof(*dpu_enc), GFP_KERNEL);
> if (!dpu_enc)
> - return ERR_PTR(ENOMEM);
> + return ERR_PTR(-ENOMEM);
>
> rc = drm_encoder_init(dev, &dpu_enc->base, &dpu_encoder_funcs,
> drm_enc_mode, NULL);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/msm/dpu: Fix usage of ERR_PTR()
2020-06-20 10:26 ` Zenghui Yu
@ 2020-06-20 16:27 ` Rob Clark
0 siblings, 0 replies; 3+ messages in thread
From: Rob Clark @ 2020-06-20 16:27 UTC (permalink / raw)
To: Zenghui Yu
Cc: linux-arm-msm, dri-devel, freedreno, Linux Kernel Mailing List,
Sean Paul, David Airlie, Daniel Vetter, Jeykumar Sankaran,
wanghaibin.wang
On Sat, Jun 20, 2020 at 3:26 AM Zenghui Yu <yuzenghui@huawei.com> wrote:
>
> ping for this obvious fix...
Hi, thanks, but there is already a similar fix in msm-next:
commit aa472721c8dbe1713cf510f56ffbc56ae9e14247
Refs: v5.7-rc5-33-gaa472721c8db
Author: Chen Tao <chentao107@huawei.com>
AuthorDate: Mon Jun 8 09:48:59 2020 +0800
Commit: Rob Clark <robdclark@chromium.org>
CommitDate: Thu Jun 11 20:07:21 2020 -0700
drm/msm/dpu: fix error return code in dpu_encoder_init
Fix to return negative error code -ENOMEM with the use of
ERR_PTR from dpu_encoder_init.
Fixes: 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")
Signed-off-by: Chen Tao <chentao107@huawei.com>
Signed-off-by: Rob Clark <robdclark@chromium.org>
BR,
-R
>
> On 2020/5/28 21:08, Zenghui Yu wrote:
> > ERR_PTR() is used in the kernel to encode an usual *negative* errno code
> > into a pointer. Passing a positive value (ENOMEM) to it will break the
> > following IS_ERR() check.
> >
> > Though memory allocation is unlikely to fail, it's still worth fixing.
> > And grepping shows that this is the only misuse of ERR_PTR() in kernel.
> >
> > Fixes: 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")
> > Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
> > ---
> > drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> > index a1b79ee2bd9d..a2f6b688a976 100644
> > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> > @@ -2173,7 +2173,7 @@ struct drm_encoder *dpu_encoder_init(struct drm_device *dev,
> >
> > dpu_enc = devm_kzalloc(dev->dev, sizeof(*dpu_enc), GFP_KERNEL);
> > if (!dpu_enc)
> > - return ERR_PTR(ENOMEM);
> > + return ERR_PTR(-ENOMEM);
> >
> > rc = drm_encoder_init(dev, &dpu_enc->base, &dpu_encoder_funcs,
> > drm_enc_mode, NULL);
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-20 16:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 13:08 [PATCH] drm/msm/dpu: Fix usage of ERR_PTR() Zenghui Yu
2020-06-20 10:26 ` Zenghui Yu
2020-06-20 16:27 ` Rob Clark
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).