From: Helge Deller <deller@gmx.de>
To: "Markus Elfring" <Markus.Elfring@web.de>,
kernel-janitors@vger.kernel.org, linux-fbdev@vger.kernel.org,
dri-devel@lists.freedesktop.org,
"Javier Martinez Canillas" <javierm@redhat.com>,
"Michal Koutný" <mkoutny@suse.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Zheng Wang" <zyytlz.wz@163.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
cocci@inria.fr, 1395428693sheep@gmail.com,
alex000young@gmail.com, hackerzheng666@gmail.com
Subject: Re: [PATCH 1/4] fbdev: imsttfb: Fix error handling in init_imstt()
Date: Thu, 25 May 2023 19:39:15 +0200 [thread overview]
Message-ID: <446a2a2a-155b-1fe3-44f3-89033b80ad34@gmx.de> (raw)
In-Reply-To: <1d7228fb-f1f8-364c-aa29-5719a9da1fc6@web.de>
On 5/25/23 07:33, Markus Elfring wrote:
>>> The return value was overlooked from a call of
>>> the function “fb_alloc_cmap”.
>>>
>>> * Thus use a corresponding error check.
>>>
>>> * Add two jump targets so that a bit of exception handling
>>> can be better reused at the end of this function.
> …
>>> +++ b/drivers/video/fbdev/imsttfb.c
> …
>>> @@ -1452,17 +1452,25 @@ static int init_imstt(struct fb_info *info)
>>> FBINFO_HWACCEL_FILLRECT |
>>> FBINFO_HWACCEL_YPAN;
>>>
>>> - fb_alloc_cmap(&info->cmap, 0, 0);
>>> + ret = fb_alloc_cmap(&info->cmap, 0, 0);
>>> + if (ret)
>>> + goto release_framebuffer;
>>>
>>> if (register_framebuffer(info) < 0) {
>>> - framebuffer_release(info);
>>> - return -ENODEV;
>>> + fb_dealloc_cmap(&info->cmap);
>>> + goto e_nodev;
>>> }
>>>
>>> tmp = (read_reg_le32(par->dc_regs, SSTATUS) & 0x0f00) >> 8;
>>> fb_info(info, "%s frame buffer; %uMB vram; chip version %u\n",
>>> info->fix.id, info->fix.smem_len >> 20, tmp);
>>> return 0;
>>> +
>>> +e_nodev:
>>> + ret = -ENODEV;
>>
>> I think the return value isn't checked at all, so you could
>> simply return below "-ENODEV" for all cases (instead of "return ret").
>> Then you don't need the e_nodev label and can simplify the flow.
>
> Can it be helpful to distinguish involved error codes better?
No.
Helge
prev parent reply other threads:[~2023-05-25 17:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-27 3:08 [PATCH v2] video: imsttfb: Fix use after free bug in imsttfb_probe due to lack of error-handling of init_imstt Zheng Wang
2023-05-11 17:03 ` Helge Deller
2023-05-22 15:36 ` Michal Koutný
2023-05-22 18:02 ` Helge Deller
[not found] ` <97807a2d-ccf2-1fbf-06f7-085bb1bdf451@web.de>
[not found] ` <38cd2e4b-3df4-6c69-b790-5762d24e2c29@web.de>
2023-05-24 18:11 ` [PATCH 3/4] fbdev: imsttfb: Move a variable assignment for an error code in imsttfb_probe() Helge Deller
[not found] ` <c551c670-7458-ed50-eb2f-5a2b7ba421a8@web.de>
2023-05-24 18:20 ` [PATCH 1/4] fbdev: imsttfb: Fix error handling in init_imstt() Helge Deller
[not found] ` <1d7228fb-f1f8-364c-aa29-5719a9da1fc6@web.de>
2023-05-25 17:39 ` Helge Deller [this message]
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=446a2a2a-155b-1fe3-44f3-89033b80ad34@gmx.de \
--to=deller@gmx.de \
--cc=1395428693sheep@gmail.com \
--cc=Markus.Elfring@web.de \
--cc=alex000young@gmail.com \
--cc=cocci@inria.fr \
--cc=dri-devel@lists.freedesktop.org \
--cc=hackerzheng666@gmail.com \
--cc=javierm@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=tzimmermann@suse.de \
--cc=zyytlz.wz@163.com \
/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
all inboxes | Powered by JetHome®