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=-10.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 8F54BC43444 for ; Mon, 7 Jan 2019 13:06:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5690221736 for ; Mon, 7 Jan 2019 13:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866367; bh=uyosTlheWnsWWO+QGX1AtcGvPSDy1oofwoma0I39X+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zq/Q3RTOhmUH1lcMku8Z7oFLRfSx54Dksmxk/rhuzImulKA3LFUUfbLii4EfRiLlr QOPvMUoMK3Dy1oulM3h3jFM8IPpmWRGwzq0u1q1ICWEmdS8alL/GkuRMe7UBkR2aFE C5NcaV6OdBLG7FrkujgPekK1OMieiBx248ol4to8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731434AbfAGNFO (ORCPT ); Mon, 7 Jan 2019 08:05:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:52922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731426AbfAGNFK (ORCPT ); Mon, 7 Jan 2019 08:05:10 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 37A902089F; Mon, 7 Jan 2019 13:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866309; bh=uyosTlheWnsWWO+QGX1AtcGvPSDy1oofwoma0I39X+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1ggIzvqbDSwx1wciKxL+lbPuU+WnnNiq91s1zuLHjrkIRvFu8TVidbi0QPqCheJH lkUjC3axAOKCDOYrlDWkT0SUQ2v6OzYJ/Hhxjzbqy5gc7su+FzEVeWX9Si6Zc2e2Da ab4E5+R00ErImhRQ7Wvnxn6B2VBCbGx3DZQCe1vo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cong Wang , "David S. Miller" , syzbot+5e5e969e525129229052@syzkaller.appspotmail.com Subject: [PATCH 4.9 15/71] net/wan: fix a double free in x25_asy_open_tty() Date: Mon, 7 Jan 2019 13:32:44 +0100 Message-Id: <20190107105331.880690467@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.280153213@linuxfoundation.org> References: <20190107105330.280153213@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit d5c7c745f254c6cb98b3b3f15fe789b8bd770c72 ] When x25_asy_open() fails, it already cleans up by itself, so its caller doesn't need to free the memory again. It seems we still have to call x25_asy_free() to clear the SLF_INUSE bit, so just set these pointers to NULL after kfree(). Reported-and-tested-by: syzbot+5e5e969e525129229052@syzkaller.appspotmail.com Fixes: 3b780bed3138 ("x25_asy: Free x25_asy on x25_asy_open() failure.") Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/wan/x25_asy.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c @@ -488,8 +488,10 @@ static int x25_asy_open(struct net_devic /* Cleanup */ kfree(sl->xbuff); + sl->xbuff = NULL; noxbuff: kfree(sl->rbuff); + sl->rbuff = NULL; norbuff: return -ENOMEM; }