All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-07 15:09 ` Colin King
  0 siblings, 0 replies; 15+ messages in thread
From: Colin King @ 2020-12-07 15:09 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, Chunfeng Yun,
	Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger, CK Hu,
	chunhui dai, dri-devel, linux-arm-kernel, linux-mediatek
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently there is a null pointer check for hdmi_phy that implies it
may be null, however a dev_err messages dereferences this potential null
pointer.  Avoid a null pointer dereference by only emitting the dev_err
message if hdmi_phy is non-null.  It is a moot point if the error message
needs to be printed at all, but since this is a relatively new piece of
code it may be useful to keep the message in for the moment in case there
are unforseen errors that need to be reported.

Addresses-Coverity: ("Dereference after null check")
Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
index c5c61f5a9ea0..5184054783c7 100644
--- a/drivers/phy/mediatek/phy-mtk-hdmi.c
+++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
@@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
 	    hdmi_phy->conf->hdmi_phy_disable_tmds)
 		return &mtk_hdmi_phy_dev_ops;
 
-	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
-		return NULL;
+	if (hdmi_phy)
+		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
+			return NULL;
 }
 
 static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,
-- 
2.29.2


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

* [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-07 15:09 ` Colin King
  0 siblings, 0 replies; 15+ messages in thread
From: Colin King @ 2020-12-07 15:09 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, Chunfeng Yun,
	Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger, CK Hu,
	chunhui dai, dri-devel, linux-arm-kernel, linux-mediatek
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently there is a null pointer check for hdmi_phy that implies it
may be null, however a dev_err messages dereferences this potential null
pointer.  Avoid a null pointer dereference by only emitting the dev_err
message if hdmi_phy is non-null.  It is a moot point if the error message
needs to be printed at all, but since this is a relatively new piece of
code it may be useful to keep the message in for the moment in case there
are unforseen errors that need to be reported.

Addresses-Coverity: ("Dereference after null check")
Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
index c5c61f5a9ea0..5184054783c7 100644
--- a/drivers/phy/mediatek/phy-mtk-hdmi.c
+++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
@@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
 	    hdmi_phy->conf->hdmi_phy_disable_tmds)
 		return &mtk_hdmi_phy_dev_ops;
 
-	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
-		return NULL;
+	if (hdmi_phy)
+		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
+			return NULL;
 }
 
 static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,
-- 
2.29.2

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

* [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-07 15:09 ` Colin King
  0 siblings, 0 replies; 15+ messages in thread
From: Colin King @ 2020-12-07 15:09 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, Chunfeng Yun,
	Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger, CK Hu,
	chunhui dai, dri-devel, linux-arm-kernel, linux-mediatek
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently there is a null pointer check for hdmi_phy that implies it
may be null, however a dev_err messages dereferences this potential null
pointer.  Avoid a null pointer dereference by only emitting the dev_err
message if hdmi_phy is non-null.  It is a moot point if the error message
needs to be printed at all, but since this is a relatively new piece of
code it may be useful to keep the message in for the moment in case there
are unforseen errors that need to be reported.

Addresses-Coverity: ("Dereference after null check")
Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
index c5c61f5a9ea0..5184054783c7 100644
--- a/drivers/phy/mediatek/phy-mtk-hdmi.c
+++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
@@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
 	    hdmi_phy->conf->hdmi_phy_disable_tmds)
 		return &mtk_hdmi_phy_dev_ops;
 
-	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
-		return NULL;
+	if (hdmi_phy)
+		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
+			return NULL;
 }
 
 static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,
-- 
2.29.2


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-07 15:09 ` Colin King
  0 siblings, 0 replies; 15+ messages in thread
From: Colin King @ 2020-12-07 15:09 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, Chunfeng Yun,
	Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger, CK Hu,
	chunhui dai, dri-devel, linux-arm-kernel, linux-mediatek
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently there is a null pointer check for hdmi_phy that implies it
may be null, however a dev_err messages dereferences this potential null
pointer.  Avoid a null pointer dereference by only emitting the dev_err
message if hdmi_phy is non-null.  It is a moot point if the error message
needs to be printed at all, but since this is a relatively new piece of
code it may be useful to keep the message in for the moment in case there
are unforseen errors that need to be reported.

Addresses-Coverity: ("Dereference after null check")
Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
index c5c61f5a9ea0..5184054783c7 100644
--- a/drivers/phy/mediatek/phy-mtk-hdmi.c
+++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
@@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
 	    hdmi_phy->conf->hdmi_phy_disable_tmds)
 		return &mtk_hdmi_phy_dev_ops;
 
-	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
-		return NULL;
+	if (hdmi_phy)
+		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
+			return NULL;
 }
 
 static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-07 15:09 ` Colin King
  0 siblings, 0 replies; 15+ messages in thread
From: Colin King @ 2020-12-07 15:09 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, Chunfeng Yun,
	Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger, CK Hu,
	chunhui dai, dri-devel, linux-arm-kernel, linux-mediatek
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently there is a null pointer check for hdmi_phy that implies it
may be null, however a dev_err messages dereferences this potential null
pointer.  Avoid a null pointer dereference by only emitting the dev_err
message if hdmi_phy is non-null.  It is a moot point if the error message
needs to be printed at all, but since this is a relatively new piece of
code it may be useful to keep the message in for the moment in case there
are unforseen errors that need to be reported.

Addresses-Coverity: ("Dereference after null check")
Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
index c5c61f5a9ea0..5184054783c7 100644
--- a/drivers/phy/mediatek/phy-mtk-hdmi.c
+++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
@@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
 	    hdmi_phy->conf->hdmi_phy_disable_tmds)
 		return &mtk_hdmi_phy_dev_ops;
 
-	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
-		return NULL;
+	if (hdmi_phy)
+		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
+			return NULL;
 }
 
 static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,
-- 
2.29.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
  2020-12-07 15:09 ` Colin King
                     ` (2 preceding siblings ...)
  (?)
@ 2020-12-08  1:50   ` Chunfeng Yun
  -1 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2020-12-08  1:50 UTC (permalink / raw)
  To: Colin King
  Cc: Chun-Kuang Hu, Philipp Zabel, Kishon Vijay Abraham I, Vinod Koul,
	Matthias Brugger, CK Hu, chunhui dai, dri-devel,
	linux-arm-kernel, linux-mediatek, kernel-janitors, linux-kernel

On Mon, 2020-12-07 at 15:09 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently there is a null pointer check for hdmi_phy that implies it
> may be null, however a dev_err messages dereferences this potential null
> pointer.  Avoid a null pointer dereference by only emitting the dev_err
> message if hdmi_phy is non-null.  It is a moot point if the error message
> needs to be printed at all, but since this is a relatively new piece of
> code it may be useful to keep the message in for the moment in case there
> are unforseen errors that need to be reported.
> 
> Addresses-Coverity: ("Dereference after null check")
> Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> index c5c61f5a9ea0..5184054783c7 100644
> --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
>  	    hdmi_phy->conf->hdmi_phy_disable_tmds)
>  		return &mtk_hdmi_phy_dev_ops;
>  
> -	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> -		return NULL;
> +	if (hdmi_phy)
> +		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> +			return NULL;
indentation: one tab before return

Thanks

>  }
>  
>  static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,


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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-08  1:50   ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2020-12-08  1:50 UTC (permalink / raw)
  To: Colin King
  Cc: Chun-Kuang Hu, chunhui dai, kernel-janitors, linux-kernel,
	dri-devel, Kishon Vijay Abraham I, Vinod Koul, linux-mediatek,
	Matthias Brugger, linux-arm-kernel

T24gTW9uLCAyMDIwLTEyLTA3IGF0IDE1OjA5ICswMDAwLCBDb2xpbiBLaW5nIHdyb3RlOg0KPiBG
cm9tOiBDb2xpbiBJYW4gS2luZyA8Y29saW4ua2luZ0BjYW5vbmljYWwuY29tPg0KPiANCj4gQ3Vy
cmVudGx5IHRoZXJlIGlzIGEgbnVsbCBwb2ludGVyIGNoZWNrIGZvciBoZG1pX3BoeSB0aGF0IGlt
cGxpZXMgaXQNCj4gbWF5IGJlIG51bGwsIGhvd2V2ZXIgYSBkZXZfZXJyIG1lc3NhZ2VzIGRlcmVm
ZXJlbmNlcyB0aGlzIHBvdGVudGlhbCBudWxsDQo+IHBvaW50ZXIuICBBdm9pZCBhIG51bGwgcG9p
bnRlciBkZXJlZmVyZW5jZSBieSBvbmx5IGVtaXR0aW5nIHRoZSBkZXZfZXJyDQo+IG1lc3NhZ2Ug
aWYgaGRtaV9waHkgaXMgbm9uLW51bGwuICBJdCBpcyBhIG1vb3QgcG9pbnQgaWYgdGhlIGVycm9y
IG1lc3NhZ2UNCj4gbmVlZHMgdG8gYmUgcHJpbnRlZCBhdCBhbGwsIGJ1dCBzaW5jZSB0aGlzIGlz
IGEgcmVsYXRpdmVseSBuZXcgcGllY2Ugb2YNCj4gY29kZSBpdCBtYXkgYmUgdXNlZnVsIHRvIGtl
ZXAgdGhlIG1lc3NhZ2UgaW4gZm9yIHRoZSBtb21lbnQgaW4gY2FzZSB0aGVyZQ0KPiBhcmUgdW5m
b3JzZWVuIGVycm9ycyB0aGF0IG5lZWQgdG8gYmUgcmVwb3J0ZWQuDQo+IA0KPiBBZGRyZXNzZXMt
Q292ZXJpdHk6ICgiRGVyZWZlcmVuY2UgYWZ0ZXIgbnVsbCBjaGVjayIpDQo+IEZpeGVzOiBiZTI4
YjY1MDdjNDYgKCJkcm0vbWVkaWF0ZWs6IHNlcGFyYXRlIGhkbWkgcGh5IHRvIGRpZmZlcmVudCBm
aWxlIikNCj4gU2lnbmVkLW9mZi1ieTogQ29saW4gSWFuIEtpbmcgPGNvbGluLmtpbmdAY2Fub25p
Y2FsLmNvbT4NCj4gLS0tDQo+ICBkcml2ZXJzL3BoeS9tZWRpYXRlay9waHktbXRrLWhkbWkuYyB8
IDUgKysrLS0NCj4gIDEgZmlsZSBjaGFuZ2VkLCAzIGluc2VydGlvbnMoKyksIDIgZGVsZXRpb25z
KC0pDQo+IA0KPiBkaWZmIC0tZ2l0IGEvZHJpdmVycy9waHkvbWVkaWF0ZWsvcGh5LW10ay1oZG1p
LmMgYi9kcml2ZXJzL3BoeS9tZWRpYXRlay9waHktbXRrLWhkbWkuYw0KPiBpbmRleCBjNWM2MWY1
YTllYTAuLjUxODQwNTQ3ODNjNyAxMDA2NDQNCj4gLS0tIGEvZHJpdmVycy9waHkvbWVkaWF0ZWsv
cGh5LW10ay1oZG1pLmMNCj4gKysrIGIvZHJpdmVycy9waHkvbWVkaWF0ZWsvcGh5LW10ay1oZG1p
LmMNCj4gQEAgLTg0LDggKzg0LDkgQEAgbXRrX2hkbWlfcGh5X2Rldl9nZXRfb3BzKGNvbnN0IHN0
cnVjdCBtdGtfaGRtaV9waHkgKmhkbWlfcGh5KQ0KPiAgCSAgICBoZG1pX3BoeS0+Y29uZi0+aGRt
aV9waHlfZGlzYWJsZV90bWRzKQ0KPiAgCQlyZXR1cm4gJm10a19oZG1pX3BoeV9kZXZfb3BzOw0K
PiAgDQo+IC0JZGV2X2VycihoZG1pX3BoeS0+ZGV2LCAiRmFpbGVkIHRvIGdldCBkZXYgb3BzIG9m
IHBoeVxuIik7DQo+IC0JCXJldHVybiBOVUxMOw0KPiArCWlmIChoZG1pX3BoeSkNCj4gKwkJZGV2
X2VycihoZG1pX3BoeS0+ZGV2LCAiRmFpbGVkIHRvIGdldCBkZXYgb3BzIG9mIHBoeVxuIik7DQo+
ICsJCQlyZXR1cm4gTlVMTDsNCmluZGVudGF0aW9uOiBvbmUgdGFiIGJlZm9yZSByZXR1cm4NCg0K
VGhhbmtzDQoNCj4gIH0NCj4gIA0KPiAgc3RhdGljIHZvaWQgbXRrX2hkbWlfcGh5X2Nsa19nZXRf
ZGF0YShzdHJ1Y3QgbXRrX2hkbWlfcGh5ICpoZG1pX3BoeSwNCg0K

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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-08  1:50   ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2020-12-08  1:50 UTC (permalink / raw)
  To: Colin King
  Cc: Chun-Kuang Hu, chunhui dai, kernel-janitors, linux-kernel,
	dri-devel, Kishon Vijay Abraham I, CK Hu, Vinod Koul,
	linux-mediatek, Philipp Zabel, Matthias Brugger,
	linux-arm-kernel

On Mon, 2020-12-07 at 15:09 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently there is a null pointer check for hdmi_phy that implies it
> may be null, however a dev_err messages dereferences this potential null
> pointer.  Avoid a null pointer dereference by only emitting the dev_err
> message if hdmi_phy is non-null.  It is a moot point if the error message
> needs to be printed at all, but since this is a relatively new piece of
> code it may be useful to keep the message in for the moment in case there
> are unforseen errors that need to be reported.
> 
> Addresses-Coverity: ("Dereference after null check")
> Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> index c5c61f5a9ea0..5184054783c7 100644
> --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
>  	    hdmi_phy->conf->hdmi_phy_disable_tmds)
>  		return &mtk_hdmi_phy_dev_ops;
>  
> -	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> -		return NULL;
> +	if (hdmi_phy)
> +		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> +			return NULL;
indentation: one tab before return

Thanks

>  }
>  
>  static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-08  1:50   ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2020-12-08  1:50 UTC (permalink / raw)
  To: Colin King
  Cc: Chun-Kuang Hu, chunhui dai, kernel-janitors, linux-kernel,
	dri-devel, Kishon Vijay Abraham I, CK Hu, Vinod Koul,
	linux-mediatek, Philipp Zabel, Matthias Brugger,
	linux-arm-kernel

On Mon, 2020-12-07 at 15:09 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently there is a null pointer check for hdmi_phy that implies it
> may be null, however a dev_err messages dereferences this potential null
> pointer.  Avoid a null pointer dereference by only emitting the dev_err
> message if hdmi_phy is non-null.  It is a moot point if the error message
> needs to be printed at all, but since this is a relatively new piece of
> code it may be useful to keep the message in for the moment in case there
> are unforseen errors that need to be reported.
> 
> Addresses-Coverity: ("Dereference after null check")
> Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> index c5c61f5a9ea0..5184054783c7 100644
> --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
>  	    hdmi_phy->conf->hdmi_phy_disable_tmds)
>  		return &mtk_hdmi_phy_dev_ops;
>  
> -	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> -		return NULL;
> +	if (hdmi_phy)
> +		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> +			return NULL;
indentation: one tab before return

Thanks

>  }
>  
>  static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-08  1:50   ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2020-12-08  1:50 UTC (permalink / raw)
  To: Colin King
  Cc: Chun-Kuang Hu, chunhui dai, kernel-janitors, linux-kernel,
	dri-devel, Kishon Vijay Abraham I, Vinod Koul, linux-mediatek,
	Matthias Brugger, linux-arm-kernel

On Mon, 2020-12-07 at 15:09 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently there is a null pointer check for hdmi_phy that implies it
> may be null, however a dev_err messages dereferences this potential null
> pointer.  Avoid a null pointer dereference by only emitting the dev_err
> message if hdmi_phy is non-null.  It is a moot point if the error message
> needs to be printed at all, but since this is a relatively new piece of
> code it may be useful to keep the message in for the moment in case there
> are unforseen errors that need to be reported.
> 
> Addresses-Coverity: ("Dereference after null check")
> Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> index c5c61f5a9ea0..5184054783c7 100644
> --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
>  	    hdmi_phy->conf->hdmi_phy_disable_tmds)
>  		return &mtk_hdmi_phy_dev_ops;
>  
> -	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> -		return NULL;
> +	if (hdmi_phy)
> +		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> +			return NULL;
indentation: one tab before return

Thanks

>  }
>  
>  static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
  2020-12-08  1:50   ` Chunfeng Yun
                       ` (2 preceding siblings ...)
  (?)
@ 2020-12-08 12:55     ` Vinod Koul
  -1 siblings, 0 replies; 15+ messages in thread
From: Vinod Koul @ 2020-12-08 12:55 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Colin King, Chun-Kuang Hu, Philipp Zabel, Kishon Vijay Abraham I,
	Matthias Brugger, CK Hu, chunhui dai, dri-devel,
	linux-arm-kernel, linux-mediatek, kernel-janitors, linux-kernel

On 08-12-20, 09:50, Chunfeng Yun wrote:
> On Mon, 2020-12-07 at 15:09 +0000, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > Currently there is a null pointer check for hdmi_phy that implies it
> > may be null, however a dev_err messages dereferences this potential null
> > pointer.  Avoid a null pointer dereference by only emitting the dev_err
> > message if hdmi_phy is non-null.  It is a moot point if the error message
> > needs to be printed at all, but since this is a relatively new piece of
> > code it may be useful to keep the message in for the moment in case there
> > are unforseen errors that need to be reported.
> > 
> > Addresses-Coverity: ("Dereference after null check")
> > Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > index c5c61f5a9ea0..5184054783c7 100644
> > --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> > +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
> >  	    hdmi_phy->conf->hdmi_phy_disable_tmds)
> >  		return &mtk_hdmi_phy_dev_ops;
> >  
> > -	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > -		return NULL;
> > +	if (hdmi_phy)
> > +		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > +			return NULL;
> indentation: one tab before return

I have applied this and fixed the indent while applying

-- 
~Vinod

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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-08 12:55     ` Vinod Koul
  0 siblings, 0 replies; 15+ messages in thread
From: Vinod Koul @ 2020-12-08 12:55 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Chun-Kuang Hu, chunhui dai, kernel-janitors, linux-kernel,
	dri-devel, Kishon Vijay Abraham I, CK Hu, linux-mediatek,
	Philipp Zabel, Matthias Brugger, Colin King, linux-arm-kernel

On 08-12-20, 09:50, Chunfeng Yun wrote:
> On Mon, 2020-12-07 at 15:09 +0000, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > Currently there is a null pointer check for hdmi_phy that implies it
> > may be null, however a dev_err messages dereferences this potential null
> > pointer.  Avoid a null pointer dereference by only emitting the dev_err
> > message if hdmi_phy is non-null.  It is a moot point if the error message
> > needs to be printed at all, but since this is a relatively new piece of
> > code it may be useful to keep the message in for the moment in case there
> > are unforseen errors that need to be reported.
> > 
> > Addresses-Coverity: ("Dereference after null check")
> > Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > index c5c61f5a9ea0..5184054783c7 100644
> > --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> > +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
> >  	    hdmi_phy->conf->hdmi_phy_disable_tmds)
> >  		return &mtk_hdmi_phy_dev_ops;
> >  
> > -	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > -		return NULL;
> > +	if (hdmi_phy)
> > +		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > +			return NULL;
> indentation: one tab before return

I have applied this and fixed the indent while applying

-- 
~Vinod

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-08 12:55     ` Vinod Koul
  0 siblings, 0 replies; 15+ messages in thread
From: Vinod Koul @ 2020-12-08 12:55 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Chun-Kuang Hu, chunhui dai, kernel-janitors, linux-kernel,
	dri-devel, Kishon Vijay Abraham I, CK Hu, linux-mediatek,
	Philipp Zabel, Matthias Brugger, Colin King, linux-arm-kernel

On 08-12-20, 09:50, Chunfeng Yun wrote:
> On Mon, 2020-12-07 at 15:09 +0000, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > Currently there is a null pointer check for hdmi_phy that implies it
> > may be null, however a dev_err messages dereferences this potential null
> > pointer.  Avoid a null pointer dereference by only emitting the dev_err
> > message if hdmi_phy is non-null.  It is a moot point if the error message
> > needs to be printed at all, but since this is a relatively new piece of
> > code it may be useful to keep the message in for the moment in case there
> > are unforseen errors that need to be reported.
> > 
> > Addresses-Coverity: ("Dereference after null check")
> > Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > index c5c61f5a9ea0..5184054783c7 100644
> > --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> > +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
> >  	    hdmi_phy->conf->hdmi_phy_disable_tmds)
> >  		return &mtk_hdmi_phy_dev_ops;
> >  
> > -	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > -		return NULL;
> > +	if (hdmi_phy)
> > +		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > +			return NULL;
> indentation: one tab before return

I have applied this and fixed the indent while applying

-- 
~Vinod

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-08 12:55     ` Vinod Koul
  0 siblings, 0 replies; 15+ messages in thread
From: Vinod Koul @ 2020-12-08 12:55 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Chun-Kuang Hu, chunhui dai, kernel-janitors, linux-kernel,
	dri-devel, Kishon Vijay Abraham I, linux-mediatek,
	Matthias Brugger, Colin King, linux-arm-kernel

On 08-12-20, 09:50, Chunfeng Yun wrote:
> On Mon, 2020-12-07 at 15:09 +0000, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > Currently there is a null pointer check for hdmi_phy that implies it
> > may be null, however a dev_err messages dereferences this potential null
> > pointer.  Avoid a null pointer dereference by only emitting the dev_err
> > message if hdmi_phy is non-null.  It is a moot point if the error message
> > needs to be printed at all, but since this is a relatively new piece of
> > code it may be useful to keep the message in for the moment in case there
> > are unforseen errors that need to be reported.
> > 
> > Addresses-Coverity: ("Dereference after null check")
> > Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > index c5c61f5a9ea0..5184054783c7 100644
> > --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> > +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
> >  	    hdmi_phy->conf->hdmi_phy_disable_tmds)
> >  		return &mtk_hdmi_phy_dev_ops;
> >  
> > -	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > -		return NULL;
> > +	if (hdmi_phy)
> > +		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > +			return NULL;
> indentation: one tab before return

I have applied this and fixed the indent while applying

-- 
~Vinod
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message
@ 2020-12-08 12:55     ` Vinod Koul
  0 siblings, 0 replies; 15+ messages in thread
From: Vinod Koul @ 2020-12-08 12:58 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Chun-Kuang Hu, chunhui dai, kernel-janitors, linux-kernel,
	dri-devel, Kishon Vijay Abraham I, linux-mediatek,
	Matthias Brugger, Colin King, linux-arm-kernel

On 08-12-20, 09:50, Chunfeng Yun wrote:
> On Mon, 2020-12-07 at 15:09 +0000, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > Currently there is a null pointer check for hdmi_phy that implies it
> > may be null, however a dev_err messages dereferences this potential null
> > pointer.  Avoid a null pointer dereference by only emitting the dev_err
> > message if hdmi_phy is non-null.  It is a moot point if the error message
> > needs to be printed at all, but since this is a relatively new piece of
> > code it may be useful to keep the message in for the moment in case there
> > are unforseen errors that need to be reported.
> > 
> > Addresses-Coverity: ("Dereference after null check")
> > Fixes: be28b6507c46 ("drm/mediatek: separate hdmi phy to different file")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/phy/mediatek/phy-mtk-hdmi.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > index c5c61f5a9ea0..5184054783c7 100644
> > --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> > +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> > @@ -84,8 +84,9 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)
> >  	    hdmi_phy->conf->hdmi_phy_disable_tmds)
> >  		return &mtk_hdmi_phy_dev_ops;
> >  
> > -	dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > -		return NULL;
> > +	if (hdmi_phy)
> > +		dev_err(hdmi_phy->dev, "Failed to get dev ops of phy\n");
> > +			return NULL;
> indentation: one tab before return

I have applied this and fixed the indent while applying

-- 
~Vinod

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

end of thread, other threads:[~2020-12-08 12:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 15:09 [PATCH][next] drm/mediatek: avoid dereferencing a null hdmi_phy on an error message Colin King
2020-12-07 15:09 ` Colin King
2020-12-07 15:09 ` Colin King
2020-12-07 15:09 ` Colin King
2020-12-07 15:09 ` Colin King
2020-12-08  1:50 ` Chunfeng Yun
2020-12-08  1:50   ` Chunfeng Yun
2020-12-08  1:50   ` Chunfeng Yun
2020-12-08  1:50   ` Chunfeng Yun
2020-12-08  1:50   ` Chunfeng Yun
2020-12-08 12:55   ` Vinod Koul
2020-12-08 12:58     ` Vinod Koul
2020-12-08 12:55     ` Vinod Koul
2020-12-08 12:55     ` Vinod Koul
2020-12-08 12:55     ` Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.