From patchwork Fri Sep 13 15:25:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 173768 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp297009ilq; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1TWKuihl/WA/TnDCTAyOzY2uc4rf/roJtM1NlGwglgh53xbtc9SZY1Y6EWjoeanr/0Mcv X-Received: by 2002:a05:6402:2028:: with SMTP id ay8mr37172675edb.120.1568388345117; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568388345; cv=none; d=google.com; s=arc-20160816; b=NgbA7YbWgdaZYmGx1dF4j06K6xs8lvXkJT5NDJeVA/xvCTD4Lh9ksO3Y5lGo02UBcd 0Bt6oC/oEMwxWH3hTes0W4fjnKMhtb81u9xjRv+lLGZz8ZsalCw6IhVLE/X13tp4RekF 14uAm4+IiGiKBluIC7JK7v8ScDcPQFfzrt5zstFr4GwalOV12hlhz4KVM5EJXqmyGSFL BFQ3Z5y9s2rdOYa7M6kdg2PDXRD2VqK+JWoi5QChBbGj9om3QiPKYaGcT7/P35/TQ1p6 /XA/o5yrlcJNa9+YFlDqM6wg6Y9SDHRKfqlu4xT/41GZftI8aqfZwc2rW2jmKbvZF99A cXdA== 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=lYYrtoZKKFua+HEJcQ6p5DFnWP8s2VfLYApP52IS4jrrkTZHv3d7GJaRZRY8tbU3KB +KZBcBG3imBYIg4xuBH93gMy5Z+fJIR2Dd3YT1FpSZA7Q36+FHwC6eV4cgrVsff98g5f gyGnO3wk6iZGw4AlqJTX3XVPwTIEiuINX4R+Hkn0313Pyr3PvaY/5WZJHRNrmwb8p8vD iRifHJ2/TkarH4oeS3lLPf+MKyL4EAewvkb3YcAa67JSJzLSOSudFaUISBTHktIYwLeM qY8c23Pgc3S+9mTww0M85VaoDKyrOAbY4jgbTfeQEg70qciycyE0osSGdMWbcqc7Y/BM V+Jw== 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-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 s18si13258228ejb.49.2019.09.13.08.25.44; Fri, 13 Sep 2019 08:25:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S2391428AbfIMPZl (ORCPT + 15 others); Fri, 13 Sep 2019 11:25:41 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51900 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388354AbfIMPZk (ORCPT ); Fri, 13 Sep 2019 11:25:40 -0400 Received: by mail-wm1-f65.google.com with SMTP id 7so3220462wme.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=ANx9gV98LvRBB/E9Ws7XADeOv2Isqy4kBuPPJKl2oxr3SHAF/iOW75U84rpyO/ZR+Y hvAwSPpRaU5pDqT5ojUbNeXyFBjXrroIrVwl32piTj/WJpnM4imR1fjkuLMyZdMsBkWO mibQX6nyHDFI/4Z1PvbnG9096KAzjachOLFS36bEruZkhegBKrfpnLSuGktlSx41ggG5 AkFrVL7Q/LrFMIZxWkqPt478fS+OyDKEP8yWSFhmrT4ZhZzvsxTtxl8K3AlBYZ1smFNw fW0/6B3unP5ee0bGbQ7i5Y9r+VzvYZUkhK81sPm9rCIjqJ926EJyFC1Q7fxU63ZRIfzH PWrg== X-Gm-Message-State: APjAAAWhPNFkO4+xTmC0AKZADzI/kX2Am6xk96EUh5axgh4lXV21sqad SZaat1vCAMX0Gm3o5tBK2DW3qQ== 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 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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(-) -- 2.23.0 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)