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 X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C61AC47089 for ; Thu, 27 May 2021 14:41:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8044360249 for ; Thu, 27 May 2021 14:41:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234629AbhE0Omf convert rfc822-to-8bit (ORCPT ); Thu, 27 May 2021 10:42:35 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:42149 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbhE0Ome (ORCPT ); Thu, 27 May 2021 10:42:34 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 4E33C100006; Thu, 27 May 2021 14:40:59 +0000 (UTC) Date: Thu, 27 May 2021 16:40:58 +0200 From: Miquel Raynal To: Yang Yingliang Cc: , , Subject: Re: [PATCH -next] i3c: master: svc: drop free_irq of devm_request_irq allocated irq Message-ID: <20210527164058.3c9145b2@xps13> In-Reply-To: <7052d19a-54cb-d634-f195-dbd8ef37f1e7@huawei.com> References: <20210518131127.1308550-1-yangyingliang@huawei.com> <20210527120123.75f2ea09@xps13> <7052d19a-54cb-d634-f195-dbd8ef37f1e7@huawei.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yang, Yang Yingliang wrote on Thu, 27 May 2021 21:49:53 +0800: > Hi, > > On 2021/5/27 18:01, Miquel Raynal wrote: > > Hi Yang, > > > > Yang Yingliang wrote on Tue, 18 May 2021 > > 21:11:27 +0800: > > > >> irq allocated with devm_request_irq should not be freed using > >> free_irq, because doing so causes a dangling pointer, and a > >> subsequent double free. > >> > >> Reported-by: Hulk Robot > >> Signed-off-by: Yang Yingliang > >> --- > >> drivers/i3c/master/svc-i3c-master.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c > >> index 1f6ba4221817..761c9c468357 100644 > >> --- a/drivers/i3c/master/svc-i3c-master.c > >> +++ b/drivers/i3c/master/svc-i3c-master.c > >> @@ -1448,7 +1448,7 @@ static int svc_i3c_master_remove(struct platform_device *pdev) > >> if (ret) > >> return ret; > >> >> - free_irq(master->irq, master); > >> + devm_free_irq(&pdev->dev, master->irq, master); > > Wouldn't removing this call the right solution? If it's a device > > managed resource, it won't probably be needed to free it explicitly in > > the remove path. > Some drivers would expect to free irq itself, I don't get it. Drivers do not expect anything, they should just comply with the API. If robots complain because a device managed resource is being freed without the device managed helper, this does not mean that the resource should explicitly be freed, it just means that *if* it must be explicitly freed, the wrong helper is being used. > I am not sure if it's ok to remove the free_irq() in i3c, What is the link with I3C? Sorry I might be missing something but master->irq is a driver variable, I don't get the link with the I3C framework and why it would interfere. > I just keep the original logic here and avoid double free. I don't think it is sane. Calling devm_free_irq() maybe is the right solution - I don't feel like it is - but your certainly can't hide behind a 'I just want the robots to be happy' justification. Hiding bugs on purpose is not something that I personally appreciate much. Thanks, Miquèl