Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3869541pxp; Tue, 15 Mar 2022 07:54:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNYnAciEOILBmaM7XpHV9B8HlP58S7dZe/nRJNsJ45eTdnC6ebI/Wh5PtI/wcWK54Emswm X-Received: by 2002:a17:902:da89:b0:153:349c:d240 with SMTP id j9-20020a170902da8900b00153349cd240mr22095118plx.73.1647356056217; Tue, 15 Mar 2022 07:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647356056; cv=none; d=google.com; s=arc-20160816; b=qV6IKlVG+lBgTs9LuE9cx+/pgcxi8+2tLciqsavyZE+RbFooLbOKEFwWdpVPRtrlN9 EH00kfY6buQgc4HnljsVXcS0PRU0sDmV7tOIlmG7lrbg94AY5eXNLzwJnRqn7I5FvhxW y2yTRc9GhK420oIH3anVhiAWk8IQnKNhlT7KBIM/7UvthhCrA909uDz30VzhG2CwmPq9 nE/fMcuL9c+VjxztJNO7DJUZojntsDcorw7OfM9T3w5BfLD5GVrvCyRNlWsGZ34qceXK wBBZeGXUUUtYyAgg+GL7zjT7+vXyqDiTOERAImiLJWcnDHPflJkFxqBY7EHcbbfJPKtI kkvw== 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=jI59i5PlxgnfPZRrxiCLGlgu7DCcZRJdrK2IrbhCIuY=; b=Tcx8yVTXMPdF7o0WlwtZzR+fcF0aDuHIiGN/E/IS1jUX/SlV1KtieF6kRfdputPKty qnHMmEbrTViPUnA6br3h84ciKBLRVKopO2CGVvJSy4Ur7JXfzJXVqKeLQg+LjaWJO11J HtTuiRtSfpnO4YKCSbqBdVA9yMVaoeFwtOv1U4i464Vc2HRdC0Juz0hq/mQ0BASZD8OP CRKhqbAI4boiSZMH1OC39wGD+YXDDJmyKfGD8KfB/RI9mbAnF3BDqcDYHoKyRg18xJ+k cydhx25/XLYKbbRwMNVX8cRg/lj7zE7xfkZLBVxIQJBnsn+rI6hy5YFnHCUOxwb+/DTr xq9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EOQ1oZFi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a65468b000000b00373219f7ff4si18779120pgr.289.2022.03.15.07.54.02; Tue, 15 Mar 2022 07:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EOQ1oZFi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S241491AbiCNM1f (ORCPT + 99 others); Mon, 14 Mar 2022 08:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241394AbiCNMSE (ORCPT ); Mon, 14 Mar 2022 08:18:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13EF04B43F; Mon, 14 Mar 2022 05:12:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4E3E5612FF; Mon, 14 Mar 2022 12:12:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8383C340E9; Mon, 14 Mar 2022 12:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647259949; bh=moZZ85LDf9khSYKSwiQkuRWcmP/GMvfFbmMPYnMwabY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EOQ1oZFiHkYsoWGSWW13nnqAky9EaFQf1KPWLS79lUp1hbSgl65xasfmXMGqfnSrd XkNFgLtYi55smHkeYo37Kz2hxcQvJ/l26kdNgIPfmJ45DJERTnXoBn+VthQrAQGQqO n7rEMmS+O04vZOJfyLuRBVyJHkCGoZbjAzGmV/T8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Khoroshilov , "David S. Miller" , Sasha Levin Subject: [PATCH 5.16 016/121] mISDN: Fix memory leak in dsp_pipeline_build() Date: Mon, 14 Mar 2022 12:53:19 +0100 Message-Id: <20220314112744.580635482@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexey Khoroshilov [ Upstream commit c6a502c2299941c8326d029cfc8a3bc8a4607ad5 ] dsp_pipeline_build() allocates dup pointer by kstrdup(cfg), but then it updates dup variable by strsep(&dup, "|"). As a result when it calls kfree(dup), the dup variable contains NULL. Found by Linux Driver Verification project (linuxtesting.org) with SVACE. Signed-off-by: Alexey Khoroshilov Fixes: 960366cf8dbb ("Add mISDN DSP") Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/isdn/mISDN/dsp_pipeline.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c index e11ca6bbc7f4..c3b2c99b5cd5 100644 --- a/drivers/isdn/mISDN/dsp_pipeline.c +++ b/drivers/isdn/mISDN/dsp_pipeline.c @@ -192,7 +192,7 @@ void dsp_pipeline_destroy(struct dsp_pipeline *pipeline) int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg) { int found = 0; - char *dup, *tok, *name, *args; + char *dup, *next, *tok, *name, *args; struct dsp_element_entry *entry, *n; struct dsp_pipeline_entry *pipeline_entry; struct mISDN_dsp_element *elem; @@ -203,10 +203,10 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg) if (!list_empty(&pipeline->list)) _dsp_pipeline_destroy(pipeline); - dup = kstrdup(cfg, GFP_ATOMIC); + dup = next = kstrdup(cfg, GFP_ATOMIC); if (!dup) return 0; - while ((tok = strsep(&dup, "|"))) { + while ((tok = strsep(&next, "|"))) { if (!strlen(tok)) continue; name = strsep(&tok, "("); -- 2.34.1