Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1881119ybc; Wed, 20 Nov 2019 05:39:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxD5TO+jl8dxZkAMw/3Lws4P9VE2NuvgSyi9j0ycFsqlATDCe9hKGQ5mv3gBL/hrqHPkf8H X-Received: by 2002:a17:906:3495:: with SMTP id g21mr5682308ejb.190.1574257173289; Wed, 20 Nov 2019 05:39:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574257173; cv=none; d=google.com; s=arc-20160816; b=VsV0hdQYlyGe7uh2dG8MTSXn8RXgHjbU28VGVHI4PBfMUt3GyxNnycLY3as5h1/UUn H+8olRGAyR+NJop1ZPfE6vF5KCdyTJ/Fc3HZA55eFpaZbtyHQUwr/JKFKnWpc7ng8bSU AnAVjpshFq+52HTP4VZfhEC9A1kKy1aKA4JclLr+B8IuWTZnewoAwD+55Iu6Z22EMXEh 6VgeLY0D+PtRr02T6YpLW7imFH/Hqf7V+BE5ZQO9byfQjd2W0BdCqo0z4yoyBtTdXJww mTARlM75hNzLxqVBkdEif4vsEuYxunCo8I2Q2kod7w0xz0V9u0RKUdRV+yGI5/7YXJ6N YRbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=I0+W8z/6EOCcQ3tfE3t4eB0zRJoRZHc0Y2igo7lZ0s4=; b=V/V5mXUVIlQ2gNUGmb+fHARqiFk522JW55LXaHEw7E2jMsQ6Jl4ox9B2l8cGUUURc8 1to1Eru4aoTDBdm/hHgZr4g7G1PXrUG+KehGmATbkw/yle0WrDKdeekK+GK45KbT5Vbh MHAMRMfFCJtHUhVhhn/Ql1zZMrwbqAjiJEXzY0SKV29xprOYnRP66eJdNFtQgspOJ+XY Sg7d0vHK+GdE2x0V+Rft5e9pYIRbJ2GASfYROJFty4hh3UPtch/aNXHBAbZChsEsKF7+ rFoac3/7DoAzgB1yp9RcEzBmyddqRxOvwzl8pTcx3daFdz2AgQYCGyUeWUnQSrJCeKZL Ug4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k15si16092625ejq.153.2019.11.20.05.39.08; Wed, 20 Nov 2019 05:39:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730073AbfKTNGa (ORCPT + 99 others); Wed, 20 Nov 2019 08:06:30 -0500 Received: from mga07.intel.com ([134.134.136.100]:42091 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727965AbfKTNG3 (ORCPT ); Wed, 20 Nov 2019 08:06:29 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2019 05:06:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,221,1571727600"; d="scan'208";a="196847595" Received: from um.fi.intel.com (HELO um) ([10.237.72.57]) by orsmga007.jf.intel.com with ESMTP; 20 Nov 2019 05:06:27 -0800 From: Alexander Shishkin To: Wen Yang Cc: zhiche.yy@alibaba-inc.com, xlpang@linux.alibaba.com, Wen Yang , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com Subject: Re: [PATCH] intel_th: avoid double free in error flow In-Reply-To: <20191119173447.2454-1-wenyang@linux.alibaba.com> References: <20191119173447.2454-1-wenyang@linux.alibaba.com> Date: Wed, 20 Nov 2019 15:06:26 +0200 Message-ID: <87y2wad7e5.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wen Yang writes: > There is a possible double free issue in intel_th_subdevice_alloc: > > 651 err = intel_th_device_add_resources(thdev, res, subdev->nres); > 652 if (err) { > 653 put_device(&thdev->dev); > 654 goto fail_put_device; ---> freed > 655 } > ... > 687 fail_put_device: > 688 put_device(&thdev->dev); ---> double freed > 689 > > This patch fix it by removing the unnecessary put_device(). Unnecessary is a too generous term here. > Fixes: a753bfcfdb1f ("intel_th: Make the switch allocate its subdevices") > Signed-off-by: Wen Yang > Cc: Alexander Shishkin > Cc: Greg Kroah-Hartman > Cc: linux-kernel@vger.kernel.org Cc: stable@ is missing. > --- > drivers/hwtracing/intel_th/core.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c > index d5c1821..98d195c 100644 > --- a/drivers/hwtracing/intel_th/core.c > +++ b/drivers/hwtracing/intel_th/core.c > @@ -649,10 +649,8 @@ static inline void intel_th_request_hub_module_flush(struct intel_th *th) > } > > err = intel_th_device_add_resources(thdev, res, subdev->nres); > - if (err) { > - put_device(&thdev->dev); > + if (err) > goto fail_put_device; > - } What about the second instance of the same problem a few lines lower? Thanks, -- Alex