From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5F62C38A02 for ; Fri, 28 Oct 2022 14:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TQ2WLU0Po+2VZrAlHxhpFWWHoDCfvnX497KrZqT1V7o=; b=FBUZMRijZAWLwq yI980qnyDZGVga+OfhIp7/JkMVUohet+AS1BhAK24/kC0MRvTv0c+v78L453CwfuOkcZEbonRjQ9I SXtwNuoX1WvIyjj6l9/y8W/IJIuRD+xeBrU8xrsEcovGHF9uRP983Z/KINbdWaEH8lBqsoDr9eLfA 2DKLeUwwdp6X9Alhka3AsBe41tGAeMXaiLdMHDZGQ5C6hmH1VQLGzdjhIYwdYAzgsMjJemhWVGZzT gtcjgeAHxJ+sDyDS+9uiht1jCthsy9aIXlL+Adwp5R6sKNpufCJtlyhQ6ebOAbDkKnM58bI1uap2t 0KQcoij5bRmwDcbxtZzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooQCn-0000Y8-0i; Fri, 28 Oct 2022 14:19:29 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooQCc-0000UU-4B for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 14:19:20 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ECB6F1FB; Fri, 28 Oct 2022 07:19:22 -0700 (PDT) Received: from e120937-lin (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 350DB3F534; Fri, 28 Oct 2022 07:19:16 -0700 (PDT) Date: Fri, 28 Oct 2022 15:19:06 +0100 From: Cristian Marussi To: Dan Carpenter Cc: linux-arm-kernel@lists.infradead.org Subject: Re: [bug report] firmware: arm_scmi: Add atomic mode support to virtio transport Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_071918_330268_0AD749C4 X-CRM114-Status: GOOD ( 13.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 21, 2022 at 01:30:50PM +0300, Dan Carpenter wrote: > Hello Cristian Marussi, Hi Dan Carpenter, thanks for the report. > > The patch 5a3b7185c47c: "firmware: arm_scmi: Add atomic mode support > to virtio transport" from Feb 17, 2022, leads to the following Smatch > static checker warning: > > drivers/firmware/arm_scmi/virtio.c:471 virtio_chan_setup() > warn: 'vioch->deferred_tx_wq' from alloc_workqueue() not released on lines: 449,456,464. > > drivers/firmware/arm_scmi/virtio.c > 419 static int virtio_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, > 420 bool tx) > 421 { > 422 struct scmi_vio_channel *vioch; > 423 int index = tx ? VIRTIO_SCMI_VQ_TX : VIRTIO_SCMI_VQ_RX; > 424 int i; > 425 > 426 if (!scmi_vdev) > 427 return -EPROBE_DEFER; > 428 > 429 vioch = &((struct scmi_vio_channel *)scmi_vdev->priv)[index]; > 430 > 431 /* Setup a deferred worker for polling. */ > 432 if (tx && !vioch->deferred_tx_wq) { > 433 vioch->deferred_tx_wq = > 434 alloc_workqueue(dev_name(&scmi_vdev->dev), > 435 WQ_UNBOUND | WQ_FREEZABLE | WQ_SYSFS, > 436 0); > > This workqueue is not freed on error paths. > > 437 if (!vioch->deferred_tx_wq) > 438 return -ENOMEM; > 439 > 440 INIT_WORK(&vioch->deferred_tx_work, > 441 scmi_vio_deferred_tx_worker); > 442 } > 443 > 444 for (i = 0; i < vioch->max_msg; i++) { > 445 struct scmi_vio_msg *msg; > 446 > 447 msg = devm_kzalloc(cinfo->dev, sizeof(*msg), GFP_KERNEL); > 448 if (!msg) > 449 return -ENOMEM; > > Here etc. > > 450 > 451 if (tx) { > 452 msg->request = devm_kzalloc(cinfo->dev, > 453 VIRTIO_SCMI_MAX_PDU_SIZE, > 454 GFP_KERNEL); > 455 if (!msg->request) > 456 return -ENOMEM; > 457 spin_lock_init(&msg->poll_lock); > 458 refcount_set(&msg->users, 1); > 459 } > 460 > 461 msg->input = devm_kzalloc(cinfo->dev, VIRTIO_SCMI_MAX_PDU_SIZE, > 462 GFP_KERNEL); > 463 if (!msg->input) > 464 return -ENOMEM; > 465 > 466 scmi_finalize_message(vioch, msg); > 467 } > 468 > 469 scmi_vio_channel_ready(vioch, cinfo); > 470 > --> 471 return 0; > 472 } > Posted a fix on this, using devres devm_ for that resource (wq) now. https://lore.kernel.org/linux-arm-kernel/20221028140833.280091-6-cristian.marussi@arm.com/T/#u Thanks, Cristian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel