Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3517440pxb; Mon, 24 Jan 2022 11:13:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0eew/xnmkFe7wI8JyV5ZLYZwQje+3hrjfpvXFPDaTY6CFz6ylg7kAsFHAYNYuL2rJA0wi X-Received: by 2002:a65:6d0a:: with SMTP id bf10mr9194909pgb.264.1643051589434; Mon, 24 Jan 2022 11:13:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643051589; cv=none; d=google.com; s=arc-20160816; b=z39W34UkSfBQ4Ayi9d10VfaQM2sxB26VGe5AbrajCrTHad6JhwG4jH2J8RERKZY7OH InaCstuGctjabvCZ8ucj1q2ldELZyEX0YGtI0GGdPXul+yWd8OuSHjd+x5vSYHd9KXxf /a/VzAk5GIcWPg4yYmLjFYrDaLs0CNBUSgYkFuUjKnzCtzSZ/NCrJWw/Rs89UJeBnDN2 EZSiqdWQUYZIiiM6VHh7o8bXJSvr65hwQqh+CkQocVs4h1A1qce3RYAKOWRboFgb0EyX XoGgjSGt862ZriO0lZsHXVhdEEAFYC1LPCp+kNXYV4rwBA/AYndcrewsO9BmsgM6lQUR m4DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=zIZYwwrZXiHAeLvm9jhAYf/+xFidtK3CAhF2X4FAAhU=; b=G6RtnZRzjkd7H6M6c8TXgCeOe7NwmeMxd+3XXBB9iOwjYVbscN1cs0xYxJxrAHswWk 4J77sH5UKcwwRnO6Z+3ikL1+FPPQ3oNxvs9EuULXzMJmgCKdxZG4CaJRuo6NK0856num 002NTfLXNSDBn5QLUHMGRZYEpmcuev1Ng9Bnu+l/wfp/3f/j2gHwzCj0+3uT9qc26Ffq nzGMugFk3kDIB8RMFskSPu776PdHAnMBfjbMHKW5/9TWMb6iuIczL4ZVeVZ8kIFgNCd0 nhazLq9VtmyvBNbYsK7wKtmIkLqc8Q/Auk6YDwZ9jKRegV/iaJiPFaSDbmTyTV6dkP0P rOaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LLYps1Yi; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pc7si211310pjb.3.2022.01.24.11.12.56; Mon, 24 Jan 2022 11:13:09 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LLYps1Yi; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239639AbiAXMl3 (ORCPT + 99 others); Mon, 24 Jan 2022 07:41:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239476AbiAXMl1 (ORCPT ); Mon, 24 Jan 2022 07:41:27 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5354C06173B for ; Mon, 24 Jan 2022 04:41:27 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id v3so9989711pgc.1 for ; Mon, 24 Jan 2022 04:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zIZYwwrZXiHAeLvm9jhAYf/+xFidtK3CAhF2X4FAAhU=; b=LLYps1Yi9R8pKGogNe4tacGnqapoQzuDIzdksLti9yZzLK2h+Tbf97/vygWrIEW8DL /qmHqZ0fts2rZ6x4zwmyDRf5Tf+HIh+l+kLP2PUy6QQzG/fBegHpwy2NK+/ETyxJyYWB K8ba1N0BwgYyFFsx4+HiBZfX2aKFaRZVuaqeS8/NCrqLxaHszElmNo8qjo1cjLPbgLlB 7DIIEE5kp6JtzdugSWd1DVgytkZDVZ92oLiJyqs5EHvWlzmJtlq3asG4RJNH6zLW2OuM pFc+U9qoD6uN2loWUFbfRfG95YI+71rcZJlymHXrU1vYWY5Zd5X6Ut29GJdW1U2fQ1El jbiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zIZYwwrZXiHAeLvm9jhAYf/+xFidtK3CAhF2X4FAAhU=; b=RH3hg/k29ZYk82Ap8rCwTTQwIttx1z2QKwcpBJ8AxdH2aQqGrv6kP1KAcFHfFWFZpN OLwLqwuLFDv1KFMr9Jr0+ksOcxwGe/U3LprxTX62giheRcW7sRsRrZU0RlHrCcl+WJi8 L2QCb4DnR+JIAjyL26SdNLF1m3iZdP4VF/VzvHImJfhD3Eeg6D/67oXWJpW+KqmWaNxx CItZlUQo2T10czmWz0GdbOBd1CKOvw/SQTgAuNeBKWfpUSzrPoSeL90drJbzjpNKQrC6 DAVwyOMNNYBirTcto0BXNSm+S2/pGFsPdjdwIivA6DN5+M7X57XS2Lt+W5kAALHR59Ge OeYw== X-Gm-Message-State: AOAM530WDjd4vPgqhthcvVzGVZ0expv2Ug0ZYKtF+UTn9ZDeKM9l/nz/ x+o2Oe0qGjIMlAyM3VQqKog= X-Received: by 2002:a63:be49:: with SMTP id g9mr11621904pgo.375.1643028087135; Mon, 24 Jan 2022 04:41:27 -0800 (PST) Received: from localhost.localdomain ([159.226.95.43]) by smtp.googlemail.com with ESMTPSA id ip13sm14262578pjb.29.2022.01.24.04.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 04:41:26 -0800 (PST) From: Miaoqian Lin To: mathieu.poirier@linaro.org Cc: alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, leo.yan@linaro.org, linmq006@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mike.leach@linaro.org, suzuki.poulose@arm.com Subject: [PATCH v2] coresight: syscfg: Fix memleak on registration failure in cscfg_create_device Date: Mon, 24 Jan 2022 12:41:21 +0000 Message-Id: <20220124124121.8888-1-linmq006@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220120182822.GA1342128@p14s> References: <20220120182822.GA1342128@p14s> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org device_register() calls device_initialize(), according to doc of device_initialize: Use put_device() to give up your reference instead of freeing * @dev directly once you have called this function. To prevent potential memleak, use put_device() for error handling. Signed-off-by: Miaoqian Lin --- Changes in v2: - simply call put_device() instead of cscfg_dev_release() in the error path of cscfg_create_device. --- drivers/hwtracing/coresight/coresight-syscfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c index 43054568430f..c30989e0675f 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.c +++ b/drivers/hwtracing/coresight/coresight-syscfg.c @@ -791,7 +791,7 @@ static int cscfg_create_device(void) err = device_register(dev); if (err) - cscfg_dev_release(dev); + put_device(dev); create_dev_exit_unlock: mutex_unlock(&cscfg_mutex); -- 2.17.1