Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4326148pxj; Tue, 8 Jun 2021 11:33:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzExmJ9QnpgLdzUQOrKHHH/ZoH74yST/U9yRhpLzScfIXU7d2jAfL7v47qIHw01btGeOByk X-Received: by 2002:a17:906:f285:: with SMTP id gu5mr25014782ejb.226.1623177239037; Tue, 08 Jun 2021 11:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623177239; cv=none; d=google.com; s=arc-20160816; b=EwtIdKrfMLGg738CSCcAhC3YMXB2aEtSm0gdgvnV1yTVvhQT1E0j6luBe15vKgzXaE SPAtZpH4XmQk2prQ2zkOThHd63S9WAHxGyYXZHgSD4vgm5b1HOd5A4nTXyuHGLkF+Yh4 9iVoV1gXEMRIt5B0lw/zdfy/CdrpsLULy2r6WztL11h06ebRvX9jh4O0XeNvea1eK0Wu gJDiBIcLYlSvi+rHlO+LH43FoZN5ndqL32OR48fHWEek/UsuKy2lzPx8diepsDRdW4m/ yz7s9uhrs4gSykETAb42ZGyNmv9t7fopVHkuZ0oalY/jCis5StKfIDfBNjEn9te0QSzW Rx1w== 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=cBxzR3/QVhQJjRiMqYXRrZu3dk93ih5Yn25iuOohmy3AE/A64SbXPRjYt30Sd9NYvl MvNrX11AlERPJ+Iuomh8b6TTjWwQYEOdv8fyAkqiIOtph+jyyERi/kxes8SMYXaTLsca 1L8qSV0zi1Nh3ag39yECoDaTLl1eDgSTaLTGDAVtkvCowFoIco/0VOqMmpUwaczAj4vR Z2tcubEU5rQ3lQMUvJq5IwNjSrnU4ucy0UZAoRhLb4cA2dUo869X9q5VcVELdYs7WXpE EYaurqlESgVg9WLNxC81iHFY1UUbvhWbtGgzK7yTjWv8iOP/28KAwaYmekl4I+qrbjUk kysw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e3jSw4uU; 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 10si365104ejj.654.2021.06.08.11.33.35; Tue, 08 Jun 2021 11:33:59 -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=e3jSw4uU; 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 S234596AbhFHSd1 (ORCPT + 99 others); Tue, 8 Jun 2021 14:33:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:57858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234126AbhFHSc2 (ORCPT ); Tue, 8 Jun 2021 14:32:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8B0B0613AE; Tue, 8 Jun 2021 18:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177035; bh=3HOKnaVi71YUI+jEO9hylFIiLEbQbbKztLrOt1LrGG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e3jSw4uUQYjVQXwZRHHvFIv5CTV13AYmBlIvU14FSFiP1rIyInDlwUaUjeQ0ueB44 64SbUJb8vfeYCOL0g0o8lR2pVfSsdTbXBi7oIQHKGIgVyDM2iTTIUpoAEPWn2NbhCU /8ymxhBcrSzKUUHPKZon5iv5tCtusojo4fazBAKs= 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.9 17/29] net: caif: fix memory leak in caif_device_notify Date: Tue, 8 Jun 2021 20:27:11 +0200 Message-Id: <20210608175928.382528927@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175927.821075974@linuxfoundation.org> References: <20210608175927.821075974@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;