Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4329797pxj; Tue, 8 Jun 2021 11:39:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWgvqrTTgSd+9HeT2AZ75pK0gaUH6Ps1+xckOSkv4/p42xK3TOt6riN6bKhgronXwNo8rw X-Received: by 2002:a17:906:7fc5:: with SMTP id r5mr25495524ejs.474.1623177574927; Tue, 08 Jun 2021 11:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623177574; cv=none; d=google.com; s=arc-20160816; b=Zna7+Y7YoULLzAvff8MC8cRAaWJgCC8o1iqde1Bx0X0c56kIPiJNqaUr5VGffUM7hB SoSBV5Ds0UG3oElrBqWmRBliQbP8XfgKuPPN0x4nbmSFSQvdYxAE5WLmyIiBBLgjt0QW fVL4SdaS69NdLbpAckqxjzL+KWeXCox1ITXoQIecMTC7hTH0CraPw/SdK66NYWpv/Bql HMoJBj/mN7q1cgLDc4s4wL+1O3zEy+IH8unwjvf8fmT2wNwxtK409NKhyH4+vF6Oyp00 ZawYcDXVBvlmqlTcJAqgX1B9BHYFoL7p9TCw8WDFwsz5F5AeyUALykhYwT40zL8po0S6 UMKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vmltI18zRFw84y9SLHpJY7hX66S0DbsTk2PfXuaWEtg=; b=QdEMT7BMVSNc0nyc/xE4IpdhzKEifPwgP+Wq9sCErWrW3mOEPSka+HlXgPo6UZ9xUm sVV1QxggXb9Pt0dH+N1lIzM90creaVKslcF1z7fszIfLjGHVF44YUgFDCzsUVoNoWn+7 1hwnF80X3hceInISxhTfpQits2aKGUZ/r07Mz858EW0Mc0a7grxGWnvzWxckLobXJzO8 aciFG1L1fyyQIK/ub6jFiu9BZ9d+vlPDnoZyvyJJdkZZ6NGlIXxE2PnTn6GTCB06IVQZ UStNbd/r6Ovsof3buvIb1wNP782CfWnGv/8SxHmPCu+mZVOLL/n11gXIZXkdpyrFnqBs pY6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qzhxN0KA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si365946edu.100.2021.06.08.11.39.10; Tue, 08 Jun 2021 11:39:34 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qzhxN0KA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234229AbhFHShs (ORCPT + 99 others); Tue, 8 Jun 2021 14:37:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:57386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234529AbhFHSfo (ORCPT ); Tue, 8 Jun 2021 14:35:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B18A0613CD; Tue, 8 Jun 2021 18:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177147; bh=3HOKnaVi71YUI+jEO9hylFIiLEbQbbKztLrOt1LrGG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qzhxN0KA/o1SJEAMfXbvytW1/wLx2cLpjTzcH0tBEQeggZlixL/dmBq1ISAxp09cT rlM8p39ib2xZYtotRUsQtcjoFcUv6u7ryTaZyjlBHikOPpjlHIBHYm4G9Wrdp16qqf LYZYHvsysgqoUvCgFwJswxwYawrrn3jVNV1tMvo4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , "David S. Miller" , syzbot+7ec324747ce876a29db6@syzkaller.appspotmail.com Subject: [PATCH 4.14 17/47] net: caif: fix memory leak in caif_device_notify Date: Tue, 8 Jun 2021 20:27:00 +0200 Message-Id: <20210608175931.044693951@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175930.477274100@linuxfoundation.org> References: <20210608175930.477274100@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Pavel Skripkin commit b53558a950a89824938e9811eddfc8efcd94e1bb upstream. In case of caif_enroll_dev() fail, allocated link_support won't be assigned to the corresponding structure. So simply free allocated pointer in case of error Fixes: 7c18d2205ea7 ("caif: Restructure how link caif link layer enroll") Cc: stable@vger.kernel.org Reported-and-tested-by: syzbot+7ec324747ce876a29db6@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/caif/caif_dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/net/caif/caif_dev.c +++ b/net/caif/caif_dev.c @@ -366,6 +366,7 @@ static int caif_device_notify(struct not struct cflayer *layer, *link_support; int head_room = 0; struct caif_device_entry_list *caifdevs; + int res; cfg = get_cfcnfg(dev_net(dev)); caifdevs = caif_device_list(dev_net(dev)); @@ -391,8 +392,10 @@ static int caif_device_notify(struct not break; } } - caif_enroll_dev(dev, caifdev, link_support, head_room, + res = caif_enroll_dev(dev, caifdev, link_support, head_room, &layer, NULL); + if (res) + cfserl_release(link_support); caifdev->flowctrl = dev_flowctrl; break;