dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: "F.A.Sulaiman" <asha.16@itfac.mrt.ac.lk>
Cc: airlied@redhat.com, sean@poorly.run, tzimmermann@suse.de,
	airlied@linux.ie, daniel@ffwll.ch,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] GPU:drm: returning ENOMEM
Date: Sun, 29 Aug 2021 02:46:00 +0200	[thread overview]
Message-ID: <YSrYyANY/ol0jC6l@ravnborg.org> (raw)
In-Reply-To: <20210828154027.8198-1-asha.16@itfac.mrt.ac.lk>

Hi F.A.Sulaiman,
On Sat, Aug 28, 2021 at 09:10:27PM +0530, F.A.Sulaiman wrote:
> When memory allocation is failed this patch returns out of memory error instead of -1.
> 
> Signed-off-by: F.A. SULAIMAN <asha.16@itfac.mrt.ac.lk>
> ---
>  drivers/gpu/drm/udl/udl_connector.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
> index 3750fd216131..afebab6186ab 100644
> --- a/drivers/gpu/drm/udl/udl_connector.c
> +++ b/drivers/gpu/drm/udl/udl_connector.c
> @@ -24,7 +24,7 @@ static int udl_get_edid_block(void *data, u8 *buf, unsigned int block,
>  
>  	read_buff = kmalloc(2, GFP_KERNEL);
>  	if (!read_buff)
> -		return -1;
> +		return -ENOMEM;
>  
>  	for (i = 0; i < len; i++) {
>  		int bval = (i + block * EDID_LENGTH) << 8;

The function is only used in a context where the return value is checked
if it is o or not zero.
But it seems prudent to return a proper error code anyways.

Please revisit the function and fix the other return -1;
Propagate the error from the called function and avoid the hardcoded -1.

	Sam

  reply	other threads:[~2021-08-29  0:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-28 15:40 [PATCH] GPU:drm: returning ENOMEM F.A.Sulaiman
2021-08-29  0:46 ` Sam Ravnborg [this message]
2021-08-30 16:02 ` [PATCH v2] GPU:DRM: " F.A.Sulaiman
2021-08-30 16:06   ` Simon Ser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YSrYyANY/ol0jC6l@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=asha.16@itfac.mrt.ac.lk \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sean@poorly.run \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox