Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3074406pxb; Mon, 9 Nov 2020 01:36:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTTW1lMBomMiih22rPrMtj4trRWxJy3DEX17JdEi+5vHGS48PuNuGhp92ux+X1KQuC9eOd X-Received: by 2002:a17:906:1e04:: with SMTP id g4mr13677528ejj.72.1604914619081; Mon, 09 Nov 2020 01:36:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604914619; cv=none; d=google.com; s=arc-20160816; b=iVcSvLN2tgYhjbcwXSzaY9sHIIEh9FUQTssJmQlArpG0x4yW71qDItMUhk+sW5QPBU LwwHbgD2/d4Ut5Mvc444cN99xREJIpcxpWUClwzsm80hgfAvACnA0sB8eOZsBklbxQ6j L3ZzHFRwPpdt7QiDw7KukwKccDnDV/NJUZ43aD3mEI9E3Q2TDtCxkAuNfY7WQFhjSQ1C 6J941gtNSqPEIadEBaDwZTnEWfSCXfWZNHzoQqVXMQB1r8L9ypcEh1qY3UdFDEN2gXsR ZhxQqax4PjXKmjsmzK/gvjQ1AeXvuAoX1Hou/d2PMP8HxPaM1ajKl+juWsFS8uw68fbg XI8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PPwxVlaIyLOvR4PnG1A2SeK9kmAoXLOPLwOGWBSSRzY=; b=Yk1KCwwmiFtBwmKruiXEuNEmIpy6cuD8GTDrErfXrp6fEpLJJuej6zNU4wYEDVDUD0 IuuoaqF5iO6O7TarFmiRXcg5veuKfmUxerzyBraPA9FGB7HQYxbVMXMBLBMnwu5IGgIm PvODJbw2zQxwgWa7gF/jacDEBQNuiLvatLEM+D5jOW+pHF2qUn/lzmk8Axm/ppAKDBJM Rz7N3AyNJKXpiZPJoY5HB7Ncs1DFCUbWbtDk8BweU0x84OCjKKH9yOFR8FwcOGUm/5D9 DbgHUPVUjb4Z+hYRp9OrZ5WpBFqdF8d6Q58sT8csRQpCtznZdJ0Wzs2l3N1yvGD24JPM kuvA== 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 qx23si6636692ejb.362.2020.11.09.01.36.36; Mon, 09 Nov 2020 01:36:59 -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 S1729031AbgKIJeM (ORCPT + 99 others); Mon, 9 Nov 2020 04:34:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726176AbgKIJeM (ORCPT ); Mon, 9 Nov 2020 04:34:12 -0500 Received: from smtp3-1.goneo.de (smtp3.goneo.de [IPv6:2001:1640:5::8:37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FC4CC0613CF for ; Mon, 9 Nov 2020 01:34:12 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by smtp3.goneo.de (Postfix) with ESMTP id C282723EEDC; Mon, 9 Nov 2020 10:34:10 +0100 (CET) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -2.94 X-Spam-Level: X-Spam-Status: No, score=-2.94 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.040, BAYES_00=-1.9] autolearn=ham Received: from smtp3.goneo.de ([127.0.0.1]) by localhost (smtp3.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m8iLppu4mIMG; Mon, 9 Nov 2020 10:34:09 +0100 (CET) Received: from lem-wkst-02.lemonage (hq.lemonage.de [87.138.178.34]) by smtp3.goneo.de (Postfix) with ESMTPSA id 378B923F3C7; Mon, 9 Nov 2020 10:34:09 +0100 (CET) Date: Mon, 9 Nov 2020 10:34:01 +0100 From: Lars Poeschel To: Dan Carpenter Cc: Miguel Ojeda Sandonis , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] auxdisplay: fix use after free in lcd2s_i2c_remove() Message-ID: <20201109093401.oufzm5z3kcckloks@lem-wkst-02.lemonage> References: <20201106192415.GA2696904@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201106192415.GA2696904@mwanda> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 06, 2020 at 10:24:15PM +0300, Dan Carpenter wrote: > The kfree() needs to be moved down a line to prevent a use after free. > > Fixes: 8c9108d014c5 ("auxdisplay: add a driver for lcd2s character display") > Signed-off-by: Dan Carpenter > --- > drivers/auxdisplay/lcd2s.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/auxdisplay/lcd2s.c b/drivers/auxdisplay/lcd2s.c > index cfa5f86deeef..3eb7f04db6cb 100644 > --- a/drivers/auxdisplay/lcd2s.c > +++ b/drivers/auxdisplay/lcd2s.c > @@ -348,8 +348,8 @@ static int lcd2s_i2c_remove(struct i2c_client *i2c) > { > struct lcd2s_data *lcd2s = i2c_get_clientdata(i2c); > > - kfree(lcd2s->charlcd); > charlcd_unregister(lcd2s->charlcd); > + kfree(lcd2s->charlcd); > return 0; > } Reviewed-by: Lars P?schel Thanks, Lars