Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3262574pxx; Mon, 2 Nov 2020 04:35:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyaIfsoioam9rPNyRZLp505TVEr5aTl/w8w38//gCO18Jt05Y/qvQvdVCsLd0oyqKx95WLb X-Received: by 2002:a05:6402:1a33:: with SMTP id be19mr11589684edb.47.1604320505757; Mon, 02 Nov 2020 04:35:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604320505; cv=none; d=google.com; s=arc-20160816; b=fgJVWwkb8KYU6Zmhk0p87M6SSmEY49ZmDAgPJIvR+ouhVPqgfp/Vm9/hI3lxLjfG2R x6cOhTkdg9+dD+dP8p02e3zF1MKHNlwjn7H3rY9eONZWfC+WFjSnvX8nLg7JZ9q9Ue9C hPSJw21Nj0ePb/gyghzB4i61ZwhTQTAL4l9VgU7w1T3zCsAM03zDyuGbMQF2CzIvymsa 37NdWLeuXkWiCLMfcvy75QGoQClpXdnv+XqbcA48js8om5t6M8L1b/LUwdT0hEOMZd2O Jx692dZb2oAgnwemYyv1x+5QibAl5nBtbP5yRyjhwFcvw2OQRYHkP4lrcSypJXWnrVAZ AeAg== 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 :mime-version:user-agent:date:message-id:from:references:to:subject; bh=Gsl34ICENW+qgR8JKcC7JW+dq8dqxPtIqcdaJNdQ4V8=; b=nez2c9T7X8of2NMJB4si4exXy3TBrONB9oGV9GBGD/UO9HWHeOCvIHUhq/hKyvKU/O U9g55AHzxeCy0ggacpk9lPLoH79DSuc84xRSasms03BOuEt15vdJwniarYcQvOW0O0r0 0Mz0o6oMWtdgJgSOgjDCL7kD3IQDr5AabEhKLiUMMcSbeZYTsrCbi4t69nzFzi1nB+gZ b4j0s+RRI7+nI47ut3YG29FmGcGJI7vuGQT9xWO9nQwNCgp2hMzZD8SibQ2sjGdf2bgu aTZH+MgplJ/WmEyU6EE2TVSkXpREkEpM86zWAaOU+8KBNu3rbWbHlgFtw2lule1C/ncv NHDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r2si8704129ejr.265.2020.11.02.04.34.43; Mon, 02 Nov 2020 04:35:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728839AbgKBMcb (ORCPT + 99 others); Mon, 2 Nov 2020 07:32:31 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:6733 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728832AbgKBMca (ORCPT ); Mon, 2 Nov 2020 07:32:30 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CPskK2kPRzkdkY; Mon, 2 Nov 2020 20:32:25 +0800 (CST) Received: from [127.0.0.1] (10.57.60.129) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Mon, 2 Nov 2020 20:32:18 +0800 Subject: Re: [PATCH] drm/irq: Add irq as false detection To: Thomas Zimmermann , Tian Tao , , , , , , References: <1604315990-56787-1-git-send-email-tiantao6@hisilicon.com> <8a76d144-f8ba-bbbc-9177-53088f6dc73a@suse.de> From: "tiantao (H)" Message-ID: Date: Mon, 2 Nov 2020 20:32:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <8a76d144-f8ba-bbbc-9177-53088f6dc73a@suse.de> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.57.60.129] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/11/2 20:09, Thomas Zimmermann 写道: > Hi > > Am 02.11.20 um 12:19 schrieb Tian Tao: >> Add the detection of false for irq, so that the EINVAL is not >> returned when dev->irq_enabled is false. >> >> Signed-off-by: Tian Tao >> --- >> drivers/gpu/drm/drm_irq.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c >> index 09d6e9e..7537a3d 100644 >> --- a/drivers/gpu/drm/drm_irq.c >> +++ b/drivers/gpu/drm/drm_irq.c >> @@ -172,6 +172,9 @@ int drm_irq_uninstall(struct drm_device *dev) >> bool irq_enabled; >> int i; >> >> + if (!dev->irq_enabled || !dev) >> + return 0; >> + > > Dereferencing a pointer before NULL-checking it, is Yoda programming. :) > I'd just drop the test for !dev and assume that dev is always valid. > > I suggest to change the int return value to void and return nothing. > > Re-reading the actual implementation of this function, this location > might be too early. Further below there already is a test for > irq_enabled. Put a drm_WARN_ON around it and it should be fine. This way > the vblank handlers will be disabled and erroneous callers will see a > warning in the kernel's log. > thank you,I will send a new patch to fix that. > Best regards > Thomas > >> irq_enabled = dev->irq_enabled; >> dev->irq_enabled = false; >> >> >