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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 0A4ECC433F5 for ; Mon, 27 Dec 2021 06:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OdbN5q1DJtXm378sNOg9gcwiZj8Ye0Ljtfdt3qK2RmI=; b=2Iyj33faQGKbCc MlZ6CUQedsWcuqkqkGhtbE/nzergtMgAb2E9H+VeFSaQy9P3KW4D8pjTLw+PYKgHVd8iI9NR3VTKH c/hUkS0+4RTWZSckfymtmsoUIHltLJbkF9T0zZ62O8t3kqA2lRtGMamgIQ3Lpvf5Xz2ialKcTDFL4 uXCO/YQTGw4B/oZVVeX1KuLj32b2gnGQK7UD9TzlCzsmaQU9DYeywDaDgMakiuM09yLMcq/MVyibO ibC13U3ciLJTAdG9rc6aD+cjq5W+wphx09kDyj+VbtF3tsLsgRXWtTCJho86ZZpkos4VpIziYNeX8 0gJ7M8DfljrNNYT0s8AA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1jVX-00GFNC-7U; Mon, 27 Dec 2021 06:29:19 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1jVT-00GFMo-Ho for linux-arm-kernel@lists.infradead.org; Mon, 27 Dec 2021 06:29:16 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B3957B808C2; Mon, 27 Dec 2021 06:29:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7F29C36AEA; Mon, 27 Dec 2021 06:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1640586552; bh=nfs9cY8hI68fJLHPs5Fa7P0ypNV+LDUhpthBrDIFF8E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ABAPlhryXS4apdou9GUXwJ8i5FQcKWPhWFsKp7W0eJWH4AMZRiTk0eGETSG0DstwF 84NvaMBh07x3inS0s2BeTyjeaglKmONOOBYVNDTjwo5M006tzcriXVb+OkSmba8D9/ dbk303EYzmi5XnWPJJQaYoe70dl6LR7fAjpV0GNQ= Date: Mon, 27 Dec 2021 07:29:07 +0100 From: Greg KH To: Christophe JAILLET Cc: jk@ozlabs.org, joel@jms.id.au, alistair@popple.id.au, eajames@linux.ibm.com, andrew@aj.id.au, linux-fsi@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] fsi: Aspeed: Fix a potential double free Message-ID: References: <2cafa0607ca171ebd00ac6c7e073b46808e24f00.1640537669.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2cafa0607ca171ebd00ac6c7e073b46808e24f00.1640537669.git.christophe.jaillet@wanadoo.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211226_222915_758083_B828CBCB X-CRM114-Status: GOOD ( 24.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Dec 26, 2021 at 05:56:02PM +0100, Christophe JAILLET wrote: > 'aspeed' is a devm_alloc'ed, so there is no need to free it explicitly or > there will be a double free(). A struct device can never be devm_alloced for obvious reasons. Perhaps that is the real problem here? > Remove the 'release' function that is wrong and unneeded. > > Fixes: 606397d67f41 ("fsi: Add ast2600 master driver") > Signed-off-by: Christophe JAILLET > --- > This patch is completely theoretical. It looks good to me, but there is a > little too much indirections for me. I'm also not that familiar with > fixing issue related to 'release' function... > > ... So review with care :) > --- > drivers/fsi/fsi-master-aspeed.c | 9 --------- > 1 file changed, 9 deletions(-) > > diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c > index 8606e55c1721..4a745ccb60cf 100644 > --- a/drivers/fsi/fsi-master-aspeed.c > +++ b/drivers/fsi/fsi-master-aspeed.c > @@ -373,14 +373,6 @@ static int aspeed_master_break(struct fsi_master *master, int link) > return aspeed_master_write(master, link, 0, addr, &cmd, 4); > } > > -static void aspeed_master_release(struct device *dev) > -{ > - struct fsi_master_aspeed *aspeed = > - to_fsi_master_aspeed(dev_to_fsi_master(dev)); > - > - kfree(aspeed); > -} > - > /* mmode encoders */ > static inline u32 fsi_mmode_crs0(u32 x) > { > @@ -603,7 +595,6 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) > dev_info(&pdev->dev, "hub version %08x (%d links)\n", reg, links); > > aspeed->master.dev.parent = &pdev->dev; > - aspeed->master.dev.release = aspeed_master_release; Odd, then what deletes this device structure when the release function wants to be called? You should have gotten a big warning from the kernel when removing the device from the system at runtime, did you test this somehow? This does not look correct at all. greg k-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel