From patchwork Wed Oct 9 14:41:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 175620 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp855356ill; Wed, 9 Oct 2019 07:41:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqw06jxfypFlGPRsxGfQK2kHMxR/Fx48s0AZnj2lhqKd0BpkC5BZd3ZmbUD656SznJXyxDZp X-Received: by 2002:a05:6402:6c9:: with SMTP id n9mr3227050edy.190.1570632096770; Wed, 09 Oct 2019 07:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570632096; cv=none; d=google.com; s=arc-20160816; b=e/K7WbYBBdZ/KEW8A5gjpjlmqHG8SEQPvBcfUwHW4J3o0BO2Z3s+J9xAiMLO2BcOON Qg0QN+e91zVObGDMQfALw98rE5W2eYZnQLlPgGVxTGSFbRcB5W5MPKssdSIKHUVMI7+C jWZ7H30bHJCTQh8376ZwsrGQi0D7ZJW670/Ig+qqk5ilzEA58PZSOWzcr37WrIvgWFg1 uIqAr7uGZJOB9zX/naAec2ng3JIHrwFEY7RizyrFG/lYuGjEdziwoqjVW0RjrBbsyakP O8ltlMem32jLKt2JfB/gPLHrjflKccsHXRMMw3k+IYAiD8YVCqfym+A3mkO5rwy7XFQO DlVg== 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=Kj8kcZrV2Ie6KvU8hO/1zbuJDnDpMortIjA2JmRJQi8=; b=EC8a0Boc9eGAA7e1/VnbHHiMQEsMkVjIHxJ/YO4pFAIFzbRpjzlSdMSbIF0X3iwjh4 kCGlZqqpFcqpEHXSpvIZwstBx5pbDfOV4BDsghq8wYQxz8lxrNiCASwp6k2IaDtLIabo pJicJvo2lYdD3sWW3COBqKTx/4r52Ijs9UeO8G+Fp9f8ZntbjtFwLxCbzZ96ezRMe7Qz hKKbXzeFxV8cb5za+ITzAfateBaLZ82GliVc0EwkIdzPLSNSp/ULXO0Koox0H4BnkZN/ 1ZJ5Bb/sLeYNOBQBpy1bgS7i7rtlZSm2wkP2V5MyjhcCAYIw4gui1ACnCto83pwQ1gG5 /RCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ob7G1xVz; 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 gf9si1238818ejb.230.2019.10.09.07.41.36; Wed, 09 Oct 2019 07:41:36 -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=ob7G1xVz; 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 S1731566AbfJIOle (ORCPT + 26 others); Wed, 9 Oct 2019 10:41:34 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36324 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731400AbfJIOld (ORCPT ); Wed, 9 Oct 2019 10:41:33 -0400 Received: by mail-wm1-f66.google.com with SMTP id m18so2917083wmc.1 for ; Wed, 09 Oct 2019 07:41:32 -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=Kj8kcZrV2Ie6KvU8hO/1zbuJDnDpMortIjA2JmRJQi8=; b=ob7G1xVzMMoZbuszEsmDW7+f8TTVwcOkmedylA9Vwn+H+9MHBJX8omWH6PmCV5OMv+ 4gXH8xWhlBx4+hjOEkH/VERbpgqEWrbpmpjpaceLslclzFmNaSZSlRzr8stf5Mw9fcQR n6JVm0W5UDpiIpuMIO8MV2in1Dk5eAOY1i7+yukIWbyQWrCWeE9fwHo7za9vbWXCWJBp tjQi+IZgLN+DzJK9WFtg6Yj3xQH2Q9d9T4ICHjQxM/tAKSfax1iODY1gzqedo155bJLb SHdy1z/h7iT21ltciliox9lL8hTM779v+jbMobvwH1cCvFjZRvTN7lMgoaltO82Rf4jS ZyNQ== 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=Kj8kcZrV2Ie6KvU8hO/1zbuJDnDpMortIjA2JmRJQi8=; b=jFxtvyekBrmbCsdcEmoNn3V63j7SfY8xrdQvDPDN+g9CDpo9BhlThuF3dnWtdziXwa u4GtMi+s35Y5mP5+OHx8awlcfNo7g8baiBsh5zmZl62w+cTPTnpskaeN1oQo3IDtq9XT 8HGsLBnrcpFFTiGcU0t7ANpiLWxO9CucSgczpFSdYRYB7o1Eb1AsBY2XqYZExHs8ZtmU SC/ezyVzSVsiXMHEfOGdkbW4AtxYUjM6I/b42eFev7YJ1co4eeLv5CM9uYhZwyWFwe5U rF+4L2Uyjd1SYWejlaMaMXS8naoSIN11KTU/YtuoETNr7TV46E1opvhRwrzlovggQ8cO LVOQ== X-Gm-Message-State: APjAAAWhn7zetEkyzedmPPhdwPo8i3srzI/LNZw0QmGGub6iscpxydwk /RsQL8C2k7V+ANb1Az/1fiJF/w== X-Received: by 2002:a1c:1bd8:: with SMTP id b207mr2874814wmb.62.1570632092078; Wed, 09 Oct 2019 07:41:32 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id b7sm3031770wrx.56.2019.10.09.07.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 07:41:31 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla , Bjorn Andersson Subject: [PATCH v3 2/5] misc: fastrpc: fix memory leak from miscdev->name Date: Wed, 9 Oct 2019 15:41:20 +0100 Message-Id: <20191009144123.24583-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191009144123.24583-1-srinivas.kandagatla@linaro.org> References: <20191009144123.24583-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Bjorn Andersson --- drivers/misc/fastrpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.21.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index aa1249bb581a..c0fe3419c685 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1610,8 +1610,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) return -ENOMEM; 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)