Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4324169pxj; Tue, 8 Jun 2021 11:30:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWpo86GnEpOygJmzd/YuDwyqY/6gW3x61RWcgewKZVx+IyqkZ0V0xQoqxACKNC9mWxwIC3 X-Received: by 2002:a17:906:2da1:: with SMTP id g1mr24518833eji.47.1623177048535; Tue, 08 Jun 2021 11:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623177048; cv=none; d=google.com; s=arc-20160816; b=KiT2WGYi6w6SWpLCIItSsUf2xWzlwNXZc/pcR3UBLGstAtWBQbRDA2beiIj/gyl/kF 24ASgqV7bt+Pfood4RTiwbhTj9R/DGF0+2eDK20dsQVkQTQ3t9fIyZY1EZqg+9bZsPIF XXfVtjQDvXKGnbqb3hI+Ud1UUmXo8i/Ig+WPNbat9wvXIDwc/rjFAiydPwBAqVjPVqcc Vq4+uqerAHnOH6WuxTewE8Vhj64/CF2z3nb2KFvCTLJqjAphHlacPuux4gGY9bu8gy/h 5js6JDp12R/MAzUCwrlgwarbryhRvIvBxNZWoJl1Hd58E7cZzPTAHSatR5mApvGo+xWe 1YgA== 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=ULTnbhwo6RuvY0qRB09EzFwsHRoGqvN9nanGI+qvmDbOe+roR+mKlp1Y2qouMnjtJi I/9ppnnTnZRKxHpDPMnycYMfFr2olVGQINI80yQNKZa81Srhn+Uyl/A/sYV5oHi2P0qH KvnmqCeppW0U8ygsiVKuFDpgaH7EltcBgBn2JzybPTWzU9JMUJOGsoOajbVPs3cTxexL 09E6CuKsnkG9jL3HI8PTlIZmInG0xnOmtaqgANig630yq29A1/fIJZI9gEUj+gUuvhnh hY6KCSR7hjLvIBNrAgh5vTojOr0umAZUDuy8E1Deo0czZnLE3NTWGpJ2E0T7JFFyF55m m4jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q5DvVggo; 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 n10si427821ejk.556.2021.06.08.11.30.24; Tue, 08 Jun 2021 11:30:48 -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=q5DvVggo; 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 S232950AbhFHSag (ORCPT + 99 others); Tue, 8 Jun 2021 14:30:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:55110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232946AbhFHSaf (ORCPT ); Tue, 8 Jun 2021 14:30:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7360C613B9; Tue, 8 Jun 2021 18:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623176922; bh=3HOKnaVi71YUI+jEO9hylFIiLEbQbbKztLrOt1LrGG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q5DvVggoWdzREflohutcENbmvO6qoNHMPuM75V0eqleiVu1pDTI0T20K0bJqwtlHg +u30q3e9PVF73Dl6n/jkghZVpSJHXgKRWlfl/rfNu7QCkAmngu52OKa/v4e6zdB75V vKVebnxbEe4OK7l+XisXgv8cxNa+FAJEwiVXPdEo= 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.4 13/23] net: caif: fix memory leak in caif_device_notify Date: Tue, 8 Jun 2021 20:27:05 +0200 Message-Id: <20210608175926.969843464@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175926.524658689@linuxfoundation.org> References: <20210608175926.524658689@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;