Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4615969pxj; Wed, 12 May 2021 09:18:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcgpUrRJr2pKAD0qUu1HTN49idJU+MecW/54CmNY/9n85of3YWdDTFX3PArZaRRBJyqtOg X-Received: by 2002:a05:6512:38c6:: with SMTP id p6mr20873723lft.560.1620836299424; Wed, 12 May 2021 09:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836299; cv=none; d=google.com; s=arc-20160816; b=RVQNWwGQBlqHd7DUkis5NEp7fUmc73Rx5q42R0q0ZL6XVnvKWnUk+ihc6U9pl09Pcf nx+1SZbsI8IymosxBSu2oheynzGZ+XJlP9/B3R48e7hawhOaiWUsnE5btKvvTXhtVJa8 JdeZ3b/MjvTwA8vBqx/sKH1Y+BbgYx/zXySlJehEcJznfoy0XZ/8c/DBL4C3mslSsX1d 06Ytdgw7YoUugf/fnilKfqRlGypY2S9QTKAw/hO3Dlia/BsjHIvqExkqtoRnRGlKisKz CsDrfp9ICtHFBosZWcsJ5TzcZa8PRRzHlyEsbiUFEIOAlNLqZyAgi152NCsWHgO+cjH8 VcXw== 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=omApjcwCkMrRIuXJQ0raK1gpIrW0IQxU0SDHCeOQS60=; b=bQHKJTXFblJAlWx/FbGP8weXi0jqpBX5H+iRp+IHdvm+L0XrkgU1X9/+HsNiZIzIrx FANhVfHXlgr7DqMSzgRIbhxGgPUjGYTj6WeAQYhIGVQ4YX/F60QeT+uzPl1gs7eVWbd9 xNbyZp4eJeYj3CgO2ltj7QAh0VsFMdOJ2CpWuzx7el5iM0lMUpPmt9r5D6FvZWQdO3ff v6Tp51frTQaPClcg9ZlMLg/0ANLafISLBESyUwkuezIugByerBnZIzkyJIAqgihYcwOA XCXQJsErH3CibneUfpKdbCrHTd9TQTcn/nPMALaQUVYlpL/mHVuuLX6eEqzh6TyHY7mO BYtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=goQZKQpk; 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 s18si45509ljg.574.2021.05.12.09.17.48; Wed, 12 May 2021 09:18:19 -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=goQZKQpk; 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 S234809AbhELQNv (ORCPT + 99 others); Wed, 12 May 2021 12:13:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:48842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233442AbhELPbF (ORCPT ); Wed, 12 May 2021 11:31:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A49F61969; Wed, 12 May 2021 15:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832564; bh=xz92FOpheA9ZOF9VnEJ0f1K84zDSsAqk20jhK4woGiU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=goQZKQpkQ1+ghSPqwnOArOQ6thmorF1azoGPhSe/L+VMzmFzC8Uoqz6IamVhDghdZ Ch7AmvvjWLc0wLoU3z76E7x/LnS4vMD46nv6SvtfRdMFGKw+JXWnKHFe6OPz3MR5Hg BpF5W0z7dkZ8cGtJQl2HbqIrRxJUgipRRFdFngJw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 298/530] media: atomisp: Fix use after free in atomisp_alloc_css_stat_bufs() Date: Wed, 12 May 2021 16:46:48 +0200 Message-Id: <20210512144829.597383305@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Dan Carpenter [ Upstream commit ba11bbf303fafb33989e95473e409f6ab412b18d ] The "s3a_buf" is freed along with all the other items on the "asd->s3a_stats" list. It leads to a double free and a use after free. Link: https://lore.kernel.org/linux-media/X9dSO3RGf7r0pq2k@mwanda Fixes: ad85094b293e ("Revert "media: staging: atomisp: Remove driver"") Signed-off-by: Dan Carpenter Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 2ae50decfc8b..9da82855552d 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -948,10 +948,8 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd, dev_dbg(isp->dev, "allocating %d dis buffers\n", count); while (count--) { dis_buf = kzalloc(sizeof(struct atomisp_dis_buf), GFP_KERNEL); - if (!dis_buf) { - kfree(s3a_buf); + if (!dis_buf) goto error; - } if (atomisp_css_allocate_stat_buffers( asd, stream_id, NULL, dis_buf, NULL)) { kfree(dis_buf); -- 2.30.2