drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
devm_drm_bridge_alloc() returns ERR_PTR on failure instead of a
NULL pointer, so use IS_ERR() to check the returned pointer.
Fixes: 48f05c3b4b70 ("drm/bridge: analogix_dp: Use devm_drm_bridge_alloc() API")
Signed-off-by: Liu Ying <victor.liu@nxp.com>
---
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index ed35e567d117..86cf898a09bb 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1474,7 +1474,7 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
dp = devm_drm_bridge_alloc(dev, struct analogix_dp_device, bridge,
&analogix_dp_bridge_funcs);
- if (!dp)
+ if (IS_ERR(dp))
return ERR_PTR(-ENOMEM);
dp->dev = &pdev->dev;
--
2.34.1
Hello Liu, On Wed, 6 Aug 2025 16:54:24 +0800 Liu Ying <victor.liu@nxp.com> wrote: > devm_drm_bridge_alloc() returns ERR_PTR on failure instead of a > NULL pointer, so use IS_ERR() to check the returned pointer. > > Fixes: 48f05c3b4b70 ("drm/bridge: analogix_dp: Use devm_drm_bridge_alloc() API") > Signed-off-by: Liu Ying <victor.liu@nxp.com> > --- > drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > index ed35e567d117..86cf898a09bb 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > @@ -1474,7 +1474,7 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) > > dp = devm_drm_bridge_alloc(dev, struct analogix_dp_device, bridge, > &analogix_dp_bridge_funcs); > - if (!dp) > + if (IS_ERR(dp)) > return ERR_PTR(-ENOMEM); Good catch, thanks! You fix is correct but now I realized one additional fix is needed in the following line: - return ERR_PTR(-ENOMEM); + return ERR_PTR(dp); Can you send a v2 with that fixed? Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
On 08/06/2025, Luca Ceresoli wrote: > Hello Liu, > > On Wed, 6 Aug 2025 16:54:24 +0800 > Liu Ying <victor.liu@nxp.com> wrote: > >> devm_drm_bridge_alloc() returns ERR_PTR on failure instead of a >> NULL pointer, so use IS_ERR() to check the returned pointer. >> >> Fixes: 48f05c3b4b70 ("drm/bridge: analogix_dp: Use devm_drm_bridge_alloc() API") >> Signed-off-by: Liu Ying <victor.liu@nxp.com> >> --- >> drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c >> index ed35e567d117..86cf898a09bb 100644 >> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c >> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c >> @@ -1474,7 +1474,7 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) >> >> dp = devm_drm_bridge_alloc(dev, struct analogix_dp_device, bridge, >> &analogix_dp_bridge_funcs); >> - if (!dp) >> + if (IS_ERR(dp)) >> return ERR_PTR(-ENOMEM); > > Good catch, thanks! > > You fix is correct but now I realized one additional fix is needed in > the following line: > > - return ERR_PTR(-ENOMEM); > + return ERR_PTR(dp); You mean ERR_CAST(dp)? > > Can you send a v2 with that fixed? I find devm_drm_bridge_alloc() always returns ERR_PTR(-ENOMEM) in this driver context, so it seems fine to keep the existing ERR_PTR(-ENOMEM). If you prefer ERR_CAST(dp), I may send v2 to use ERR_CAST(dp). > > Luca > -- Regards, Liu Ying
On Wed, 6 Aug 2025 17:38:17 +0800 Liu Ying <victor.liu@nxp.com> wrote: > On 08/06/2025, Luca Ceresoli wrote: > > Hello Liu, > > > > On Wed, 6 Aug 2025 16:54:24 +0800 > > Liu Ying <victor.liu@nxp.com> wrote: > > > >> devm_drm_bridge_alloc() returns ERR_PTR on failure instead of a > >> NULL pointer, so use IS_ERR() to check the returned pointer. > >> > >> Fixes: 48f05c3b4b70 ("drm/bridge: analogix_dp: Use devm_drm_bridge_alloc() API") > >> Signed-off-by: Liu Ying <victor.liu@nxp.com> > >> --- > >> drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > >> index ed35e567d117..86cf898a09bb 100644 > >> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > >> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > >> @@ -1474,7 +1474,7 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) > >> > >> dp = devm_drm_bridge_alloc(dev, struct analogix_dp_device, bridge, > >> &analogix_dp_bridge_funcs); > >> - if (!dp) > >> + if (IS_ERR(dp)) > >> return ERR_PTR(-ENOMEM); > > > > Good catch, thanks! > > > > You fix is correct but now I realized one additional fix is needed in > > the following line: > > > > - return ERR_PTR(-ENOMEM); > > + return ERR_PTR(dp); > > You mean ERR_CAST(dp)? Ah, indeed! > > Can you send a v2 with that fixed? > > I find devm_drm_bridge_alloc() always returns ERR_PTR(-ENOMEM) in this > driver context, so it seems fine to keep the existing ERR_PTR(-ENOMEM). > If you prefer ERR_CAST(dp), I may send v2 to use ERR_CAST(dp). The documentation says: * Returns: * Pointer to new bridge, or ERR_PTR on failure. So let's follow that, which is a (relatively) immutable contract, and not the implementation which might change over time. This is also what all callers of devm_drm_bridge_alloc() do, unless I missed something. Thanks, Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
On 08/06/2025, Luca Ceresoli wrote: > On Wed, 6 Aug 2025 17:38:17 +0800 > Liu Ying <victor.liu@nxp.com> wrote: > >> On 08/06/2025, Luca Ceresoli wrote: >>> Hello Liu, >>> >>> On Wed, 6 Aug 2025 16:54:24 +0800 >>> Liu Ying <victor.liu@nxp.com> wrote: >>> >>>> devm_drm_bridge_alloc() returns ERR_PTR on failure instead of a >>>> NULL pointer, so use IS_ERR() to check the returned pointer. >>>> >>>> Fixes: 48f05c3b4b70 ("drm/bridge: analogix_dp: Use devm_drm_bridge_alloc() API") >>>> Signed-off-by: Liu Ying <victor.liu@nxp.com> >>>> --- >>>> drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c >>>> index ed35e567d117..86cf898a09bb 100644 >>>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c >>>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c >>>> @@ -1474,7 +1474,7 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) >>>> >>>> dp = devm_drm_bridge_alloc(dev, struct analogix_dp_device, bridge, >>>> &analogix_dp_bridge_funcs); >>>> - if (!dp) >>>> + if (IS_ERR(dp)) >>>> return ERR_PTR(-ENOMEM); >>> >>> Good catch, thanks! >>> >>> You fix is correct but now I realized one additional fix is needed in >>> the following line: >>> >>> - return ERR_PTR(-ENOMEM); >>> + return ERR_PTR(dp); >> >> You mean ERR_CAST(dp)? > > Ah, indeed! > >>> Can you send a v2 with that fixed? >> >> I find devm_drm_bridge_alloc() always returns ERR_PTR(-ENOMEM) in this >> driver context, so it seems fine to keep the existing ERR_PTR(-ENOMEM). >> If you prefer ERR_CAST(dp), I may send v2 to use ERR_CAST(dp). > > The documentation says: > > * Returns: > * Pointer to new bridge, or ERR_PTR on failure. > > So let's follow that, which is a (relatively) immutable contract, and > not the implementation which might change over time. Fair enough. v2 is on the way. > > This is also what all callers of devm_drm_bridge_alloc() do, unless I > missed something. > > Thanks, > Luca > -- Regards, Liu Ying
© 2016 - 2025 Red Hat, Inc.