Re: [PATCH v2] s390/raw3270: Handle memory allocation failures in raw3270_setup_console()
From: Heiko Carstens
Date: Tue Jun 25 2024 - 05:39:59 EST
On Tue, Jun 25, 2024 at 04:44:47PM +0900, Yunseong Kim wrote:
> Hi Heiko,
> >> - set_bit(RAW3270_FLAGS_CONSOLE, &rp->flags);
> >> -
> >> + }
> >> rc = ccw_device_enable_console(cdev);
> >> if (rc) {
> >> ccw_device_destroy_console(cdev);
> >> + kfree(ascebc);
> >> + kfree(rp);
> >> return ERR_PTR(rc);
> >> }
> >> + set_bit(RAW3270_FLAGS_CONSOLE, &rp->flags);
> >
> > Why did you move the set_bit() call?
>
> Thank you for the code review Heiko.
>
> While writing patch version 2, I spent a lot of time thinking about this
> part. Previously, even if function "ccw_device_enable_console" failed,
> the flag was set to RAW3270_FLAGS_CONSOLE and returned.
>
> I think it would be more appropriate to set the bit after everything
> succeeded, so I included and submitted this code in v2 patch.
>
> I’d appreciate hearing your thoughts on this!
"More appropriate" is not a technical reason. Please don't mix
different things into a single patch. If the set_bit() call needs to
be moved then you need to provide a technical reason for it.