From: Markus Elfring <Markus.Elfring@web.de>
To: "Yunseong Kim" <yskelg@gmail.com>,
linux-s390@vger.kernel.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Bornträger" <borntraeger@linux.ibm.com>,
"Harald Freudenberger" <freude@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
"Sven Schnelle" <svens@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>, MichelleJin <shjy180909@gmail.com>
Subject: Re: [PATCH v2] s390/raw3270: Handle memory allocation failures in raw3270_setup_console()
Date: Tue, 25 Jun 2024 10:12:43 +0200 [thread overview]
Message-ID: <70139e84-478f-42cf-a94c-61266399b37f@web.de> (raw)
In-Reply-To: <20240625013225.17076-2-yskelg@gmail.com>
> … Thus add corresponding return value checks.
I suggest to move this sentence into a subsequent text line.
> The allocated each memory areas are immediately overwritten by the called
> function zero-initialisation be omitted by calling the "kmalloc" instead.
It seems that you stumbled on wording difficulties according to my previous
patch review suggestion.
I find the intended change more appropriate for another update step.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc5#n168
> After "ccw_device_enable_console" succeeds, set the bit raw3270 flag to
> RAW3270_FLAGS_CONSOLE.
Why do you find such an adjustment relevant here?
> Fixes: 33403dcfcdfd ("[S390] 3270 console: convert from bootmem to slab")
> Cc: linux-s390@vger.kernel.org
Would you like to specify a “stable tag”?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v6.10-rc5#n34
> ---
I would appreciate a version description behind the marker line.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc5#n713
…
> +++ b/drivers/s390/char/raw3270.c
> @@ -811,18 +811,28 @@ struct raw3270 __init *raw3270_setup_console(void)
> if (IS_ERR(cdev))
> return ERR_CAST(cdev);
>
> - rp = kzalloc(sizeof(*rp), GFP_KERNEL | GFP_DMA);
> - ascebc = kzalloc(256, GFP_KERNEL);
> + rp = kmalloc(sizeof(*rp), GFP_KERNEL | GFP_DMA);
> + if (!rp)
> + return ERR_PTR(-ENOMEM);
> + ascebc = kmalloc(256, GFP_KERNEL);
> + if (!ascebc) {
> + kfree(rp);
> + return ERR_PTR(-ENOMEM);
> + }
> rc = raw3270_setup_device(cdev, rp, ascebc);
> - if (rc)
> + if (rc) {
> + kfree(ascebc);
> + kfree(rp);
> return ERR_PTR(rc);
…
Please take further software design options better into account.
A) goto chain
https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources
B) scope-based resource management
https://elixir.bootlin.com/linux/v6.10-rc5/source/include/linux/slab.h#L282
Regards,
Markus
prev parent reply other threads:[~2024-06-25 8:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 1:32 [PATCH v2] s390/raw3270: Handle memory allocation failures in raw3270_setup_console() yskelg
2024-06-25 6:31 ` Heiko Carstens
2024-06-25 7:44 ` Yunseong Kim
2024-06-25 9:39 ` Heiko Carstens
2024-06-25 8:12 ` Markus Elfring [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=70139e84-478f-42cf-a94c-61266399b37f@web.de \
--to=markus.elfring@web.de \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=freude@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=shjy180909@gmail.com \
--cc=svens@linux.ibm.com \
--cc=yskelg@gmail.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