Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1011106ybe; Fri, 13 Sep 2019 09:40:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdgQuiPyWDi2I3+DKPqBdjT1LPAl6GLaL1I4xDGLtOF3puSC4DcN2w17pNUGL/JjUq/8ar X-Received: by 2002:aa7:d8cf:: with SMTP id k15mr49557607eds.195.1568392857506; Fri, 13 Sep 2019 09:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568392857; cv=none; d=google.com; s=arc-20160816; b=FWDC8/mknVbSgVAIb+gshC6t5BwOnpDkKrJCNg2Gjk6qdVMwF6aPF0RfBkUWjqOPuq RNZ+pC7cqPDwIpaOVgZMmUp2Q+BhdrJXBZQWWEVeNyTSRhV1knzRx2apva0ZX4uS3HYN inqCeyLbXT0T16nMS212guIDDrUSFK7FTK02g8yz3qltEj7m+09B08qgX455Z5a3tntq Dntcs0luUPJcCtEvZPUEy7J/1tsidqs0h/JDMoHw4ggfr68u2T8F/zTCecA92Ic6KrHb KZZM3+fFN5cPBrVzKatLg5d5TW2Ze4NBkd0mcEMtpMKK7lDHe3SKTVoWvXCruNrE/qxY hwSQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e/lU9jG5N7e3DGoVf3x6D+rPQKudYImqOCFLI9QDQ8k=; b=Wxmek5BF2dJa4OZkYyQaUBG4fah2laOvAuC9e/STYt54u4DcgJro7SBgTehfiyhbu6 ArSCIjIpGKOVNSDMXvs1r8TseJ+xPC5N+vBl3FV4RuagAsd9lWlj8Es+YHqAQw0ck6M8 alOr+tPwcIK2rGqp3R4tPopV3IhIm9k4zU6VMbaOnBS8vAML/K75k1un6IOwwBO/LmJc dCJ9JHLoeR5C881xhiaqGpq3XrJ3c4jElDiUBcw3PCDL3vYquA5R2sMZwg9Wu3eSXQKC QXYB8gtd9hUhVSCI91zFWKPMTcBRsmWteOPNxgUwadANO9tvFKlbiZLVxPTAxqEmAV0+ jKGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gqpn2OIi; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w40si17121331edd.319.2019.09.13.09.40.34; Fri, 13 Sep 2019 09:40:57 -0700 (PDT) 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=@linaro.org header.s=google header.b=gqpn2OIi; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403851AbfIMPZn (ORCPT + 99 others); Fri, 13 Sep 2019 11:25:43 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36003 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390565AbfIMPZm (ORCPT ); Fri, 13 Sep 2019 11:25:42 -0400 Received: by mail-wm1-f67.google.com with SMTP id t3so3247029wmj.1 for ; Fri, 13 Sep 2019 08:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e/lU9jG5N7e3DGoVf3x6D+rPQKudYImqOCFLI9QDQ8k=; b=gqpn2OIiZdZR/ujxmZ4QKVcE0P5jWYnbShSyKwt+5OJvAk//DlifLDtqxfEpAUw/l6 T/DR/0AYFynhblu0cN/SaXf0Xm/FdY9gTY17Cf+x5rj0ebfHya+BtDzrR2GF0JeAmAH7 FBlDd/omPPc+NNNMxizNCrTMDPoo4YUiNtEBLP4tEJQh2+4lpgQjMCiHIXzAZMdIKtFd 4nUHzhjGxdp75h5RzCVqrfg8ei+s69essebdX5VSw4Q8BunyAPSq7JDaG8vwaCBc0mE8 EZE8mPG3Ez3C8SDVWhgaF0Blqb+gUejmRiFvL2MjAd6xJAoP0p4mIwrRifcogsqKZOKP datg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e/lU9jG5N7e3DGoVf3x6D+rPQKudYImqOCFLI9QDQ8k=; b=oI7XYWu/ZoN+HWPpdtYW7UQjC4ee8IzI6OA5+SOZzCD2HKXey0S17iwdev4i0ZKnoT 5+YimLIb+oQXcjMtJU6ymxf5sUK9ZFANQtOTFraa7vamO6dr3tJd0H3EA6wcq+1CJmlf mMaY8uqR2EOYT3m6zmJVLDvfqGu3JxIBNiCSns6pvmuLl4iUMVRK84JQriYhCLbIotNS 1c9Q/BIVlZn+3cMUOEOl/TqoXdSE53vPaozTlXZvuU88GX/ZwBNqkXUm0PdGt313tj8o KDRIu1JfJla+E3s6n+vnPDh0HAPZ7bwEm6/+b3S8GX1uqajZcfuWoKqDgFbY7BrlnUSp 0d4w== X-Gm-Message-State: APjAAAXQNhTvTp3ZDCgzn3Ktyn3FMrAgnc0AdlsgShWlSCfM2TxtYaj6 kSDUKCdqbxGGr3il1N/S/tfDaQ== X-Received: by 2002:a1c:f518:: with SMTP id t24mr3725176wmh.98.1568388338932; Fri, 13 Sep 2019 08:25:38 -0700 (PDT) Received: from localhost.localdomain (69.red-83-35-113.dynamicip.rima-tde.net. [83.35.113.69]) by smtp.gmail.com with ESMTPSA id d9sm48717728wrc.44.2019.09.13.08.25.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Sep 2019 08:25:38 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, gregkh@linuxfoundation.org, arnd@arndb.de, srinivas.kandagatla@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/5] misc: fastrpc: fix memory leak from miscdev->name Date: Fri, 13 Sep 2019 17:25:29 +0200 Message-Id: <20190913152532.24484-3-jorge.ramirez-ortiz@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> References: <20190913152532.24484-1-jorge.ramirez-ortiz@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla Fix a memory leak in miscdev->name by using devm_variant Orignally reported by kmemleak: [] kmemleak_alloc+0x50/0x84 [] __kmalloc_track_caller+0xe8/0x168 [] kvasprintf+0x78/0x100 [] kasprintf+0x50/0x74 [] fastrpc_rpmsg_probe+0xd8/0x20c [] rpmsg_dev_probe+0xa8/0x148 [] really_probe+0x208/0x248 [] driver_probe_device+0x98/0xc0 [] __device_attach_driver+0x9c/0xac [] bus_for_each_drv+0x60/0x8c [] __device_attach+0x8c/0x100 [] device_initial_probe+0x20/0x28 [] bus_probe_device+0x34/0x7c [] device_add+0x420/0x498 [] device_register+0x24/0x2c Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 8903388993d3..bc03500bfe60 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1599,8 +1599,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) } data->miscdev.minor = MISC_DYNAMIC_MINOR; - data->miscdev.name = kasprintf(GFP_KERNEL, "fastrpc-%s", - domains[domain_id]); + data->miscdev.name = devm_kasprintf(rdev, GFP_KERNEL, "fastrpc-%s", + domains[domain_id]); data->miscdev.fops = &fastrpc_fops; err = misc_register(&data->miscdev); if (err) -- 2.23.0