Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4379458imu; Sat, 19 Jan 2019 08:11:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN6W9JBrqdNIyHmljAmzdDRhLK9RjRoFX4C3I/1e78vEVFGA5YIEl500eSj5UA59efDICMf5 X-Received: by 2002:a17:902:930b:: with SMTP id bc11mr23899841plb.17.1547914277711; Sat, 19 Jan 2019 08:11:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547914277; cv=none; d=google.com; s=arc-20160816; b=Vq5YdB7Y0Hw8eJ9QchwzG5kdhcVB7haRaqdi4BucjdR8giClH9O0naD45k1HcdEkpS CvKS9dlCVuK59+Vl1J5ZnAH8+bDfDvUkMAaZatZUvfVhxVbLly1+BGf4FCtwmjvtNslc nm0zH9R3Dnl1JAdvS88q8kF3X8ByIK+xoeG0Py43BuC/PeL1AyA0b8AvO9AKVzmmzn9U 3uLcKMnOmoEj59Mgeb4pDueh/e0emomFnF1/YzzCUDGWMAG+LZMfJOldksVWUhMIvw3J R/G5EliTRsPWLXYTQAXcJHd/EkylYXb03Ssw6yzhQ3VaReIdMkpFV9nRDMju9LAHcPQC A+Dg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=FG5gUckh9DdyTJHbL2iXHBN4K0kVRyYdpq6JIbdw0Ro=; b=h5T0wGOrCljs+KZmf2St0EgX7Iq5W6PUuJ51EzcdUJEti7lUIipm+LKhkL2+z+6xVj AIViMpVLucVm76T4PKPxsIx408rq7GHB5YZLfN5CcA9V8b0U4yCR2gl++pusybKOLaIL QZv1DucpD5fIxd7xDlQ5hq2AbPL4DeAO+vdUHFzVivoo2Q2FQfOR97tQdjuVP1MzrNGR n/7q2hFseyV3tR9Zz2ZigvfBqDznuWLfPgOHVN9rrEcCV+h6D9CuOlV5vNIwgiAXWfqK UwePHpZNyWSl+Sk79X/cumyzx1ZyrKBjeaHnc8VRpaj+AyOyDBXRH4+z14OKHt7GltA4 mVLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SpRsvzGK; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w16si4251491plk.192.2019.01.19.08.11.01; Sat, 19 Jan 2019 08:11:17 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SpRsvzGK; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728596AbfASQIx (ORCPT + 99 others); Sat, 19 Jan 2019 11:08:53 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:51421 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728312AbfASQIx (ORCPT ); Sat, 19 Jan 2019 11:08:53 -0500 Received: by mail-it1-f194.google.com with SMTP id w18so11041750ite.1; Sat, 19 Jan 2019 08:08:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=FG5gUckh9DdyTJHbL2iXHBN4K0kVRyYdpq6JIbdw0Ro=; b=SpRsvzGKDdBkVURRWTBndRJKZolvsy2LyvvLFetH+1jV9b92fXDx62Ck39JS6g3oif G8waZxwGc9KTrTPae271IBw2LFXG2DYuuBGuJ0a442w6H1w+Gg8WjCTarM/u8z4bNi5I gNH5KrFIEhoFQfuUTIwGWD7jiuRma3DPw4AGasq9rvh8esQMVR5b1m/xp8+dROwyFcEs sHeu2irrJ58sfUpGyHX/s2muXfpf2f+vZijl2N4GNeoZN0JY50Lf2klohx26ucFzvIxP fJfZ54BwkwUaLLcC442MaWN6aLqrsBeIWZjF0INjj1MjwvpmVoUlU+qjg2yTg8N2ABBr Arrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=FG5gUckh9DdyTJHbL2iXHBN4K0kVRyYdpq6JIbdw0Ro=; b=HTieTL0Kpo1/OUrjgqeKKYP62hUrY3wYIvnShcqDBzCL8NN8MYZ09F571j7LN/EgTg 9Ygk0ALaxZjyUMKHiRMO5WzY3WfrN6KEP6/gcRT42NuxiqYzn/l33ve/t4XDHqJiompe +W5VwxoEvIvXhNLNvmxBeKedtFr6mQLo54bubyIdPJERkpYyRoi9ipAOYCsrLnY0NEuT ccLwiGkhXK4Y1Jmyo1s75vxW8qaS38HgESX4eyxP38yUnxw7uaAv2nKzHpxpNeCGbmCV i2IVb5eZOpcoV7d4kUXMr2ssBhUrlBFDyPupsq+IRI9UTsRoVdQ4+zSQ4nL1gXsrwEDM iGKA== X-Gm-Message-State: AJcUukfdJpRHKVBC1/a02VEypsYWCGz+LptKv949SIY3XmnI44sQqYIG hftyzq41ggAaQXc83/kfGWws9BzAYWfeyLfKmG07JbXNhs/noQ== X-Received: by 2002:a02:5184:: with SMTP id s126mr12851368jaa.12.1547914132538; Sat, 19 Jan 2019 08:08:52 -0800 (PST) MIME-Version: 1.0 References: <20190119050256.22520-1-tiny.windzz@gmail.com> In-Reply-To: From: Frank Lee Date: Sun, 20 Jan 2019 00:08:35 +0800 Message-ID: Subject: Re: [PATCH] PM / devfreq: fix mem leak and missing check of return value in devfreq_add_device() To: cwchoi00@gmail.com Cc: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Linux PM list , linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Also, you better to add following codes to free the memory of > 'devfreq->trans_table' and 'devfreq->time_in_state' because this patch > handles the memory leak of 'trans_table' and 'time_in_state' > variables. Hi Chanwoo: Isn't that the mem requested by the devm_ API automatically freed when the device is detached? So we don't need to pay attention to free these mem. Thanks=EF=BC=8C Yangtao > > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c > index 0ae3de7..945f5f1 100644 > --- a/drivers/devfreq/devfreq.c > +++ b/drivers/devfreq/devfreq.c > @@ -593,6 +593,9 @@ static void devfreq_dev_release(struct device *dev) > devfreq->profile->exit(devfreq->dev.parent); > > mutex_destroy(&devfreq->lock); > + kfree(devfreq->trans_table); > + kfree(devfreq->time_in_state); > kfree(devfreq); > } > > -- > Best Regards, > Chanwoo Choi > Samsung Electronics