Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5556501rwb; Tue, 22 Nov 2022 01:27:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf4DNyFc/fxbETomtQI7dCl/IG2a9HmlUyWUQjhyTT4iIHdmv+Ps89phQJ2+8zqU4BRNWDEC X-Received: by 2002:a05:6a00:cd5:b0:56d:7aaa:f1ea with SMTP id b21-20020a056a000cd500b0056d7aaaf1eamr4075557pfv.69.1669109254013; Tue, 22 Nov 2022 01:27:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669109254; cv=none; d=google.com; s=arc-20160816; b=kWxLg9MEGAuXG0eoGCWGwYETRO83q0FO/VqujSJnLQ+Xonv9MkzQmzlEU6OQAdqkrw WeDhrg8pOqXfadS1w9HSUMZ6zcEJXim700WEUsTliJWu0fUaH4jIYpLpD2XdKDNpxn5h ++HI+v6TFvC37erYntfjgD04sWP0wBWxDemPqgFme9kH4dXLBuFkv65KgyD9XYOuT+yA x1lEC1meBYPNmjBi/j71297sXX9kUajjXTJHD4B7zOKA4er0HqRdmbrrxrE09QtspRp+ xHrG7t1v0dPmR7mPgcWqBL3fLEE6BguReG0VlJzq8ozkmpQx+6/kphQU3XVFcBzsZjf3 5jQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=0wQK6rFUoShHhGlr0hNprX/8fEbuw4qQrSI8ec4h5j8=; b=1Kl4lqfuKDIuFz7MpXDg1gRF7iEtmnXg9NnTHhXDuhKrgC3PKVWhKjsCLwoDiTz9zk 0W12FPkXMFkgOzPzWm//pEOG5h8hAEaLAWCnet8jzKJpfZSv9sQT0Ovl6DyuWEQzLhNz w2DbrCn2v6rA8LdJniYySerO2DmmTVB/cKsUmwrb+8R+9+GdMfVs2JCcZaOtCKuXxJvD vEpkYTxc4YImNAZJ6sn70BiZLxy/Sr4wSUFy5Fmifm/fodsNlHlkU7y8K5BCmwdyd5pB ffA2voEkoOx3ITkPcEMBcfyGIFW2Z5zoMPdBqsS92cfBu7LR9nfEtguy5kC1yKbzfa4N Q1jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CVkZzf1b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u24-20020a634558000000b004767da74fa7si14141071pgk.368.2022.11.22.01.27.22; Tue, 22 Nov 2022 01:27:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CVkZzf1b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233265AbiKVJMZ (ORCPT + 91 others); Tue, 22 Nov 2022 04:12:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233266AbiKVJMN (ORCPT ); Tue, 22 Nov 2022 04:12:13 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE02747329 for ; Tue, 22 Nov 2022 01:12:11 -0800 (PST) Received: from [192.168.1.100] (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id E202B6602AC7; Tue, 22 Nov 2022 09:12:09 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1669108330; bh=XQs9y9qnM68EyMoHPrxiDgq88Oc9TnrG2mdHxwEI2sQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=CVkZzf1bm1eq3dnFoEDL8E2t9w+rllcHe6eClLcXsHRs+VHN3hKPjLV5NNgxlWMET eCx0667iQP4uhsgDs0Ept2jcZ+WRzK2yvZ+iscJPNmW3/3ygNLS+BSQh90MtVLdVD/ MWNJoQHV0S4QC2P5aJ+ftzSDFA4sDFr9UU6JgqR+1Qse4U7PDJb3mdOK0v1Ea5O1oX dYDT2WE7ySmP1NVyuln3YcUSAec7mQqv7o+88+519dSNMboAtN0GUhGifNWE0UzpW4 Y4O/McoElEA37GpxO7TJ9v+kFSWtsRDMXUk/tTthX6tDSzp7UWo/Uz+SgOZx2FgzhS /s9t1wFc4bXNg== Message-ID: <1ff98f52-93e1-d375-47ae-30b74068ea5b@collabora.com> Date: Tue, 22 Nov 2022 10:12:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH] drm/mediatek: Clean dangling pointer on bind error path To: =?UTF-8?B?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , Chun-Kuang Hu Cc: kernel@collabora.com, "Nancy . Lin" , Daniel Vetter , David Airlie , Matthias Brugger , Philipp Zabel , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org References: <20221121223717.3429913-1-nfraprado@collabora.com> Content-Language: en-US From: AngeloGioacchino Del Regno In-Reply-To: <20221121223717.3429913-1-nfraprado@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 21/11/22 23:37, NĂ­colas F. R. A. Prado ha scritto: > mtk_drm_bind() can fail, in which case drm_dev_put() is called, > destroying the drm_device object. However a pointer to it was still > being held in the private object, and that pointer would be passed along > to DRM in mtk_drm_sys_prepare() if a suspend were triggered at that > point, resulting in a panic. Clean the pointer when destroying the > object in the error path to prevent this from happening. > > Signed-off-by: NĂ­colas F. R. A. Prado > Fixes tag please! :-) Cheers, Angelo > --- > > drivers/gpu/drm/mediatek/mtk_drm_drv.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c > index 39a42dc8fb85..a21ff1b3258c 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c > @@ -514,6 +514,7 @@ static int mtk_drm_bind(struct device *dev) > err_deinit: > mtk_drm_kms_deinit(drm); > err_free: > + private->drm = NULL; > drm_dev_put(drm); > return ret; > }