Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp158192ybg; Tue, 28 Jul 2020 02:34:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy38JT4Rzyi03gMFEBUR0XbG9qaDcrpmdSyb5E9tEN2RK44ZBxp27RKrgADhLNWItNk0WaI X-Received: by 2002:a17:906:2a5b:: with SMTP id k27mr24267702eje.82.1595928881727; Tue, 28 Jul 2020 02:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595928881; cv=none; d=google.com; s=arc-20160816; b=V//0DMDUCfusNd/YdXJynlDZYsPKoV801EQdcUhDPt786zFSdQv2TG+HHP55TO+D8/ M2IkBp2wiWQ/X7+eQxAnfquAGNmBhDo922+fZkkIEIeepWVGrbF6ULV52+Hqsz+ELpkc 9YYT4AJh0uLcpmsC1yVMBYen3h5EIgsSBaN5wyZxPAP6i7XO8HrV//hwVYpqB7e0Rvik +AIvuRa+SVMyT7XxYLrVW4TyfXkyRy3Fs7NZaNE+bIoIxTjex03+aTwuzZMlwPyTgI+8 rZDT/X1wvsvFoIwFfjIXRNNHHpKnGAJr3WRXyjZlfedkwn9elGiGxtgm+hdSvy5vIWU+ b05w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=CcizFx4vAz2ogW40amkTxt3W9Zgp6fJw6N1GpJ6XQZ8=; b=LHk6tkTlcERgOH3QLcxHC1Re3zPtEjxck4zEwSW9g0PcFdjsgu4A6egE/FocNwiVLC Bto0OQ7+8bag+sqhqO6QrbMkSJFa8AG24TPaIKYkX13aWxkqqqQlDgY0HpOPHKEuVL0/ zKrJoV3JTH6USXYhACxPCRaCNMGwayVoyOhFjTbW/y1vgyMCghXMFBft6T309W/DrAaV JycehpInWsjC7xeYMC/AlmpaQUaPoqLd/aZocXQBXSjPPDVQk4sU7LgQZAJMbOzPmyGP 3MyxbRSpXF8+51SbZY5tCTUyuAXb9e0Wb7Ipq3FpgS1JwpCWNbwiZfiMOOCi5dagtIQ5 e/CA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 30si6339943edq.190.2020.07.28.02.34.18; Tue, 28 Jul 2020 02:34:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728275AbgG1JeJ (ORCPT + 99 others); Tue, 28 Jul 2020 05:34:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728130AbgG1JeI (ORCPT ); Tue, 28 Jul 2020 05:34:08 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36DF9C061794 for ; Tue, 28 Jul 2020 02:34:08 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 89BA72958A0 Subject: Re: [PATCH] regulator: cros-ec-regulator: Fix double free of desc->name. To: Pi-Hsun Shih Cc: Liam Girdwood , Mark Brown , Benson Leung , Guenter Roeck , Prashant Malani , "open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK" References: <20200728091909.2009771-1-pihsun@chromium.org> From: Enric Balletbo i Serra Message-ID: Date: Tue, 28 Jul 2020 11:34:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200728091909.2009771-1-pihsun@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pi-Hsun, Thank you for your patch and to send upstream. On 28/7/20 11:19, Pi-Hsun Shih wrote: > The desc->name field is allocated with devm_kstrdup, but is also kfreed > on the error path, causing it to be double freed. Remove the kfree on > the error path. > > Fixes: 8d9f8d57e023 ("regulator: Add driver for cros-ec-regulator") > Signed-off-by: Pi-Hsun Shih Reviewed-by: Enric Balletbo i Serra > --- > drivers/regulator/cros-ec-regulator.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c > index 35f97246bc48..cee259eb0213 100644 > --- a/drivers/regulator/cros-ec-regulator.c > +++ b/drivers/regulator/cros-ec-regulator.c > @@ -222,18 +222,13 @@ static int cros_ec_regulator_probe(struct platform_device *pdev) > > drvdata->dev = devm_regulator_register(dev, &drvdata->desc, &cfg); > if (IS_ERR(drvdata->dev)) { > - ret = PTR_ERR(drvdata->dev); > dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); > - goto free_name; > + return PTR_ERR(drvdata->dev); > } > > platform_set_drvdata(pdev, drvdata); > > return 0; > - > -free_name: > - kfree(desc->name); > - return ret; > } > > static const struct of_device_id regulator_cros_ec_of_match[] = { > > base-commit: 8d9f8d57e023893bfa708d83e3a787e77766a378 >