kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915/display: fix missing null check on allocated dsb object
@ 2020-06-16 11:42 Colin King
  2020-06-16 11:54 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2020-06-16 11:42 UTC (permalink / raw)
  To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie,
	Daniel Vetter, Animesh Manna, Maarten Lankhorst, intel-gfx,
	dri-devel
  Cc: kernel-janitors, linux-kernel

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

Currently there is no null check for a failed memory allocation
on the dsb object and without this a null pointer dereference
error can occur. Fix this by adding a null check.

Note: added a drm_err message in keeping with the error message style
in the function.

Addresses-Coverity: ("Dereference null return")
Fixes: afeda4f3b1c8 ("drm/i915/dsb: Pre allocate and late cleanup of cmd buffer")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/i915/display/intel_dsb.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
index 24e6d63e2d47..566fa72427b3 100644
--- a/drivers/gpu/drm/i915/display/intel_dsb.c
+++ b/drivers/gpu/drm/i915/display/intel_dsb.c
@@ -271,6 +271,10 @@ void intel_dsb_prepare(struct intel_crtc_state *crtc_state)
 		return;
 
 	dsb = kmalloc(sizeof(*dsb), GFP_KERNEL);
+	if (!dsb) {
+		drm_err(&i915->drm, "DSB object creation failed\n");
+		return;
+	}
 
 	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
-- 
2.27.0.rc0

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

* Re: [PATCH] drm/i915/display: fix missing null check on allocated dsb object
  2020-06-16 11:42 [PATCH] drm/i915/display: fix missing null check on allocated dsb object Colin King
@ 2020-06-16 11:54 ` Dan Carpenter
  2020-06-16 11:56   ` Colin Ian King
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2020-06-16 11:54 UTC (permalink / raw)
  To: Colin King
  Cc: David Airlie, Animesh Manna, kernel-janitors, linux-kernel,
	dri-devel, Rodrigo Vivi, intel-gfx, Maarten Lankhorst

On Tue, Jun 16, 2020 at 12:42:21PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently there is no null check for a failed memory allocation
> on the dsb object and without this a null pointer dereference
> error can occur. Fix this by adding a null check.
> 
> Note: added a drm_err message in keeping with the error message style
> in the function.

Don't give in to peer pressure!  That's like being a lemming when Disney
film makers come to push you off the cliff to create the 1958 nature
film "White Wilderness".

regards,
dan carpenter

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

* Re: [PATCH] drm/i915/display: fix missing null check on allocated dsb object
  2020-06-16 11:54 ` Dan Carpenter
@ 2020-06-16 11:56   ` Colin Ian King
  2020-06-30 11:28     ` Jani Nikula
  0 siblings, 1 reply; 4+ messages in thread
From: Colin Ian King @ 2020-06-16 11:56 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Airlie, Animesh Manna, kernel-janitors, linux-kernel,
	dri-devel, Rodrigo Vivi, intel-gfx, Maarten Lankhorst

On 16/06/2020 12:54, Dan Carpenter wrote:
> On Tue, Jun 16, 2020 at 12:42:21PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently there is no null check for a failed memory allocation
>> on the dsb object and without this a null pointer dereference
>> error can occur. Fix this by adding a null check.
>>
>> Note: added a drm_err message in keeping with the error message style
>> in the function.
> 
> Don't give in to peer pressure!  That's like being a lemming when Disney
> film makers come to push you off the cliff to create the 1958 nature
> film "White Wilderness".

:-)

> 
> regards,
> dan carpenter
> 

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

* Re: [PATCH] drm/i915/display: fix missing null check on allocated dsb object
  2020-06-16 11:56   ` Colin Ian King
@ 2020-06-30 11:28     ` Jani Nikula
  0 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2020-06-30 11:28 UTC (permalink / raw)
  To: Colin Ian King, Dan Carpenter
  Cc: David Airlie, Animesh Manna, kernel-janitors, linux-kernel,
	dri-devel, Rodrigo Vivi, intel-gfx, Maarten Lankhorst

On Tue, 16 Jun 2020, Colin Ian King <colin.king@canonical.com> wrote:
> On 16/06/2020 12:54, Dan Carpenter wrote:
>> On Tue, Jun 16, 2020 at 12:42:21PM +0100, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> Currently there is no null check for a failed memory allocation
>>> on the dsb object and without this a null pointer dereference
>>> error can occur. Fix this by adding a null check.
>>>
>>> Note: added a drm_err message in keeping with the error message style
>>> in the function.
>> 
>> Don't give in to peer pressure!  That's like being a lemming when Disney
>> film makers come to push you off the cliff to create the 1958 nature
>> film "White Wilderness".
>
> :-)

Pushed, thanks for the patch and smile.

BR,
Jani.


>
>> 
>> regards,
>> dan carpenter
>> 
>

-- 
Jani Nikula, Intel Open Source Graphics Center

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

end of thread, other threads:[~2020-06-30 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 11:42 [PATCH] drm/i915/display: fix missing null check on allocated dsb object Colin King
2020-06-16 11:54 ` Dan Carpenter
2020-06-16 11:56   ` Colin Ian King
2020-06-30 11:28     ` Jani Nikula

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).