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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 DE94DC28CBC for ; Wed, 6 May 2020 18:23:29 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C12AA20747 for ; Wed, 6 May 2020 18:23:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C12AA20747 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28EF76E8C4; Wed, 6 May 2020 18:23:29 +0000 (UTC) Received: from asavdk4.altibox.net (asavdk4.altibox.net [109.247.116.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA1006E8C4 for ; Wed, 6 May 2020 18:23:27 +0000 (UTC) Received: from ravnborg.org (unknown [158.248.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk4.altibox.net (Postfix) with ESMTPS id 96C608050C; Wed, 6 May 2020 20:23:24 +0200 (CEST) Date: Wed, 6 May 2020 20:23:18 +0200 From: Sam Ravnborg To: Christophe JAILLET Subject: Re: [PATCH V2] video: fbdev: w100fb: Fix a potential double free. Message-ID: <20200506182318.GA8712@ravnborg.org> References: <20200506181902.193290-1-christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200506181902.193290-1-christophe.jaillet@wanadoo.fr> User-Agent: Mutt/1.10.1 (2018-07-13) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=MOBOZvRl c=1 sm=1 tr=0 a=UWs3HLbX/2nnQ3s7vZ42gw==:117 a=UWs3HLbX/2nnQ3s7vZ42gw==:17 a=kj9zAlcOel0A:10 a=-sM3sDvmAAAA:8 a=p1g2r8j9AAAA:8 a=hD80L64hAAAA:8 a=VwQbUJbxAAAA:8 a=lUMsOl5nhcu_R7_EiuIA:9 a=CjuIK1q_8ugA:10 a=LUHx1oGsa4U61Z4w8267:22 a=GEd6vGEn79KL1p3bDQhq:22 a=AjGcO6oz07-iQ99wixmX:22 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: , Cc: linux-fbdev@vger.kernel.org, b.zolnierkie@samsung.com, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, rpurdie@rpsys.net, stable@vger.kernel.org, adaplas@pol.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Christophe On Wed, May 06, 2020 at 08:19:02PM +0200, Christophe JAILLET wrote: > Some memory is vmalloc'ed in the 'w100fb_save_vidmem' function and freed in > the 'w100fb_restore_vidmem' function. (these functions are called > respectively from the 'suspend' and the 'resume' functions) > > However, it is also freed in the 'remove' function. > > In order to avoid a potential double free, set the corresponding pointer > to NULL once freed in the 'w100fb_restore_vidmem' function. > > Fixes: aac51f09d96a ("[PATCH] w100fb: Rewrite for platform independence") > Cc: Richard Purdie > Cc: Antonino Daplas > Cc: Bartlomiej Zolnierkiewicz > Cc: # v2.6.14+ > Signed-off-by: Christophe JAILLET Thanks for the quick v2. Applied to drm-misc-next. Sam > --- > v2: - Add Cc: tags > - Reword the commit message to give the names of the functions that > allocate and free the memory. These functions are called from the > suspend and resume function. > --- > drivers/video/fbdev/w100fb.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c > index 2d6e2738b792..d96ab28f8ce4 100644 > --- a/drivers/video/fbdev/w100fb.c > +++ b/drivers/video/fbdev/w100fb.c > @@ -588,6 +588,7 @@ static void w100fb_restore_vidmem(struct w100fb_par *par) > memsize=par->mach->mem->size; > memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_extmem, memsize); > vfree(par->saved_extmem); > + par->saved_extmem = NULL; > } > if (par->saved_intmem) { > memsize=MEM_INT_SIZE; > @@ -596,6 +597,7 @@ static void w100fb_restore_vidmem(struct w100fb_par *par) > else > memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), par->saved_intmem, memsize); > vfree(par->saved_intmem); > + par->saved_intmem = NULL; > } > } > > -- > 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel