From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 958C0C433EF for ; Fri, 3 Dec 2021 14:15:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 00CE77AD32; Fri, 3 Dec 2021 14:15:36 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 56C1B7AD32 for ; Fri, 3 Dec 2021 14:15:34 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8D6B91396 for ; Fri, 3 Dec 2021 06:15:33 -0800 (PST) Received: from [192.168.99.12] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4EDC13F766 for ; Fri, 3 Dec 2021 06:15:33 -0800 (PST) Message-ID: <76a8e999-f54c-625a-1180-95ceb159cb25@foss.arm.com> Date: Fri, 3 Dec 2021 14:15:32 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH] drm/komeda: return early if drm_universal_plane_init() fails. Content-Language: en-US To: dri-devel@lists.freedesktop.org References: <95728378-3af0-2b55-0545-46d5131fa491@arm.com> <20211203100946.2706922-1-liviu.dudau@arm.com> From: Carsten Haitzler Organization: Arm Ltd. In-Reply-To: <20211203100946.2706922-1-liviu.dudau@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 12/3/21 10:09, Liviu Dudau wrote: > If drm_universal_plane_init() fails early we jump to the common cleanup code > that calls komeda_plane_destroy() which in turn could access the uninitalised > drm_plane and crash. Return early if an error is detected without going through > the common code. > > Reported-by: Steven Price > Signed-off-by: Liviu Dudau > --- > drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > index aa193c58f4bf6d9..517b94c3bcaf966 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > @@ -279,8 +279,10 @@ static int komeda_plane_add(struct komeda_kms_dev *kms, > > komeda_put_fourcc_list(formats); > > - if (err) > - goto cleanup; > + if (err) { > + kfree(kplane); > + return err; > + } > > drm_plane_helper_add(plane, &komeda_plane_helper_funcs); > > Ummm... can I disagree here? this goto cleanup I think is just fine because plane has been set before drm_universal_plane_init() is called which is before the if (err) here. komeda_plane_destroy() in cleanup: does all the right things, so this patch isn't needed. I think it's less clean as it adds a new "handle error" path special-case instance where a special case is not needed. The fix to Zhou's original patch was needed for exactly the reason Liviu said - but not this one... ?