From patchwork Wed Oct 30 15:46:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13856764 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C89142141A8; Wed, 30 Oct 2024 15:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730303199; cv=none; b=jwcMoI+4lob0B4ufFKdqSyLOyBW2RNH/GU51zKGSzYx0na33rkmYQ7vIwtkznx3isMUF76LNEOJhtSuXVohV5qjNwuc/0J7ZFTQQlkFt517JthefjFngpqZzN/cZ3P3HgSfulMYh7pztQxnpfUzpZGSlNve6rNFN9JpXbRfINkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730303199; c=relaxed/simple; bh=r7QF4PHLX5P8h0FpkWDd8f0d9a2be4wo41dlp89hp4o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C8Lt72oeiIzHP4xkjTM1KNlUEYIvRpr+8a02jS0f2iOR8xmpTDV17+5nBP/vRLFJlFC8pg+bbvncBaTi6y9B6BHC111StzBGZdNWH/WaV5cU7CpBhaenZfeR0AOTh8AHkmHj88C1Jyj2MR8ChQXADTaxF83rPlL4/NjAY+FT3h4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DSutp/5i; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DSutp/5i" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a9a26a5d6bfso1046232866b.1; Wed, 30 Oct 2024 08:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730303196; x=1730907996; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CxasEsCWEIGpOvNzhH8eScxatYKa4d9obCKEvyxu0Rw=; b=DSutp/5i4k6qJNVXlvyPyRuSfzMNOF5aJqP6bUOJBlFf5dgYNbSh3K1A1aX01h3FXk rUrkU+FepANArsU5fkXfwXg73d5o94Renms9UbnClJ2LgFJeSUv5ceK2tjqePpjxx7uh Z2zpUcrCR9kJsO3llRpaI8fUpYu7+dFd9qRojbZP5R32u8FE+6EUF6mKEg1fwx+w/mu7 dVWWAIgw2u0tRPDuL70mJu9/j1gJ5JxYxIVoOXJMmSUZLiOERiJ83z+x3nkwj8R7MZm9 k7qZ82KpAsr306VVHusa1U2KyJ7dBhrx4Pcx+lCkm3V8VM+ygHskayRPb00rxM1lXgXo G+uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303196; x=1730907996; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CxasEsCWEIGpOvNzhH8eScxatYKa4d9obCKEvyxu0Rw=; b=S1AZ/LXoPORKAgcGjtqFeLaOUZKX7I783Q4VTIQire9H0cdhJncjfrWFobrhhg940G JD/nWT5CTuR72NmzUt76hSv2cvLZ2TZa/Hg9DcuwCjE0kc80JE3v/YWwEZPs9du1wYb6 XCgQTdfjQER8rlgWjQ6epVV36Ip45K1jly79EYOD3Lof6s2o/Np3gLq97wM4+ImHHRKk DB+axi1VABm/5FUs+rew5IcK7NDjGmxBFKXcgGD5VJfCjlh0mSkPZn5I7KN2fSdn9F+y G2+/uczx3DZ22WlWbDAw6vh1MiZB4hHLq2q9saUFBQ1avR5muzeRDFgXM2asIpY7xfYl zySA== X-Forwarded-Encrypted: i=1; AJvYcCW/A5gDvNY1d62XRSANVXOWhoyrGrR5a/8lXvRikgqnoEqRr7h/moIEdJRrrYwNniogkeP3j0sv@vger.kernel.org, AJvYcCXC0UDygpbMi19TDvAm1DG3L5aFGOm6zpYv58227VuCXstxdoJ3JLZ8RqRRJZuPQyfeo2sunPU8rrhz22Q=@vger.kernel.org X-Gm-Message-State: AOJu0YxmZ7USRdQVnYSUVYPZvY8XUlf+p3LdAk8uwg441A6uixPkziBA 7jSG545zEcHKn8FpcwAoxN6bfk0fanCUMh9qBCc+57j/ATq8xWpjpYhEYg== X-Google-Smtp-Source: AGHT+IG0Fm32mxDJhFWquwLn6UmkrmH53AH/udH8AfgwmH9oyvfEAaTYZlTD6ByYK+ksWsj4jcQu5A== X-Received: by 2002:a17:907:74b:b0:a99:37f5:de59 with SMTP id a640c23a62f3a-a9de619182amr1430120266b.53.1730303195789; Wed, 30 Oct 2024 08:46:35 -0700 (PDT) Received: from [127.0.1.1] ([213.208.157.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b3a086de0sm580414766b.218.2024.10.30.08.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:46:35 -0700 (PDT) From: Javier Carrasco Date: Wed, 30 Oct 2024 16:46:21 +0100 Subject: [PATCH 1/2] Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name() Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241030-bluetooth-btbcm-node-cleanup-v1-1-fdc4b9df9fe3@gmail.com> References: <20241030-bluetooth-btbcm-node-cleanup-v1-0-fdc4b9df9fe3@gmail.com> In-Reply-To: <20241030-bluetooth-btbcm-node-cleanup-v1-0-fdc4b9df9fe3@gmail.com> To: Marcel Holtmann , Luiz Augusto von Dentz , Linus Walleij Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco , stable@vger.kernel.org X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1730303189; l=985; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=r7QF4PHLX5P8h0FpkWDd8f0d9a2be4wo41dlp89hp4o=; b=0Br1VOjdEp367ZTVHtMA6gyBQa87HqXCnGFw6tV8ZDpythWn/3AZXZrGa8jRqtoN28TJvma12 PkV5nIL6evqCkgNqVkCJQpKQkUTRyySsDLofqDDnkusU24z5sjI28UI X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Add the missing call lto of_node_put(root) in the early return to decrement the refcount and avoid leaking the resource. Cc: stable@vger.kernel.org Fixes: 63fac3343b99 ("Bluetooth: btbcm: Support per-board firmware variants") Signed-off-by: Javier Carrasco --- drivers/bluetooth/btbcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c index eef00467905e..400c2663d6b0 100644 --- a/drivers/bluetooth/btbcm.c +++ b/drivers/bluetooth/btbcm.c @@ -549,8 +549,10 @@ static const char *btbcm_get_board_name(struct device *dev) if (!root) return NULL; - if (of_property_read_string_index(root, "compatible", 0, &tmp)) + if (of_property_read_string_index(root, "compatible", 0, &tmp)) { + of_node_put(root); return NULL; + } /* get rid of any '/' in the compatible string */ board_type = devm_kstrdup(dev, tmp, GFP_KERNEL); From patchwork Wed Oct 30 15:46:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13856765 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FC2E2141AF; Wed, 30 Oct 2024 15:46:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730303202; cv=none; b=HvxoALjWEPosKuJH5XhGe79HL2Ur2Fr/EX3u0c3ajUT3iKd3EJa97q/iYFdnXFJTrQYA9bu02yYDk3dU6prYo14nYRVw1ZqHfzA0UNIsZd1CAKVS2LaVhL1jszLWpTi2cXkS05V4jr1/LzlkPM9X3SO0B4kresvNGBHCLiC8/7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730303202; c=relaxed/simple; bh=X4bS7jZBrQsTQ9pemudF62VcEvDkNDsGs6ennZLexiI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=en2kZYiQrUhRf7NRLCoABasCG/qzTtsjCetQ4SvvMEwwaheGh4dQ2eI2P1eUcRDTEDHO1HHcIflBgkBKUjLiG/W+7hup6ZwC2seN0aQLLH+WEq/YNSIECZ2wHX63icDvYAykhZRSS1mkf621ehVpy6oEuM0WtvAg3SMl2VfcxVE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IRsVs12x; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IRsVs12x" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a99ebb390a5so197107066b.1; Wed, 30 Oct 2024 08:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730303198; x=1730907998; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Ywf+/b+4z5TUeH000STbqJxWFX2lQppigAFbBYhUVZY=; b=IRsVs12xCYTN9CdsSGfDLCu9lq2+z87NFBDtgrLnP0Xn6/Y7lxw1XmRv8GfeirveI/ 6Yh7kth+ucvWSQiy1ogq8241SIvWrlRcw9VhKvfhiH5kGUfdCgzJCoHlmb3ODHt0deKz oYLms4rFKNcIdZmXMUdju8QNZJMKYLs6upxuBCI2Cd7hb1NtwIpnPRN/PTOk+vQJusae 0jPP14jgohI9x4LV3lKczSBPy+70BnhsjtJG0+u4TM58VUFRtdPbowWSlX6mHb24xNch qDwpHbSpWjmyA9xYZxAc+SSnaiBau8OvJOjOmSh3RuNh5OQzHnbUEZWiowjOAjdzbTTR tDAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303198; x=1730907998; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ywf+/b+4z5TUeH000STbqJxWFX2lQppigAFbBYhUVZY=; b=nAcQZB99Dow71DyGJfbXNijuEi/SPwmLzLMcKv4MAgL84X1jscOJ7KoIDmN0Lr/zv9 zd1s0IgyPRn+hSl23/4/xDMdrwGtsdJFsY0i6v+vSSjc/3rZ0rRQVEoA/gSbreID+jp+ M5OEQmGQKr6r0tkNbnLxBudPKtfUufJeoqxlM7ZMeLDaQ7qPurlIZ2vfiNWuOG0MhDMK DqUT9lZZzHYrLOD+bAAKsI5aXO4EbZOmm9QiiuBCkH4GKrINmnqQUhpu6uHHy7Om3LLm WbKN0FZpWLugAodm2yCWUGs8ruYvT1dsGgXJLHklIiOf+sn88zdtkfJWg5pdyfeghPIK 6Nag== X-Forwarded-Encrypted: i=1; AJvYcCVYCFJZwMJ8MQF+E6VydMAUoU0bbsfn98P3LZTbtIxf8hQvp/jq0auCuan/mNwrqhVy6T3SGYWtGpPMTnk=@vger.kernel.org X-Gm-Message-State: AOJu0YxiLJoqBGBd3C0FacwQETqUcqFUNWnqKZPXVpBrr3m4S4V1jB1C S+yQE1cf8D3oCj+amxl+Tyx6wzV64cM4U51/2mjX/fDMCwPKe+DnDyi6DQ== X-Google-Smtp-Source: AGHT+IE4kMH7781VGRzXLHNlecgeJTSwY7og38Lu++uliRPFZriSjrif96AQ2nPEDjMztByH5IXscw== X-Received: by 2002:a17:907:3f97:b0:a9a:e0b8:5bac with SMTP id a640c23a62f3a-a9e40fda6d6mr258358366b.23.1730303198168; Wed, 30 Oct 2024 08:46:38 -0700 (PDT) Received: from [127.0.1.1] ([213.208.157.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b3a086de0sm580414766b.218.2024.10.30.08.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:46:37 -0700 (PDT) From: Javier Carrasco Date: Wed, 30 Oct 2024 16:46:22 +0100 Subject: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name() Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241030-bluetooth-btbcm-node-cleanup-v1-2-fdc4b9df9fe3@gmail.com> References: <20241030-bluetooth-btbcm-node-cleanup-v1-0-fdc4b9df9fe3@gmail.com> In-Reply-To: <20241030-bluetooth-btbcm-node-cleanup-v1-0-fdc4b9df9fe3@gmail.com> To: Marcel Holtmann , Luiz Augusto von Dentz , Linus Walleij Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1730303189; l=1278; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=X4bS7jZBrQsTQ9pemudF62VcEvDkNDsGs6ennZLexiI=; b=NXX2QxMwsq+yiv1DLUCBmB+gqhH4/ShsIIesjB6CR3K6y+i/WA8HGBl1EmWcGuTG4FUtRl59w /NsEm11rEtxBpb8+HxfpCXctYow2djbBDn2x5tmCUmh9eLzzzCzfyTZ X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to a more robust approach by automating the node release when it goes out of scope, removing the need for explicit calls to of_node_put(). Signed-off-by: Javier Carrasco --- drivers/bluetooth/btbcm.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c index 400c2663d6b0..a1153ada74d2 100644 --- a/drivers/bluetooth/btbcm.c +++ b/drivers/bluetooth/btbcm.c @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = { static const char *btbcm_get_board_name(struct device *dev) { #ifdef CONFIG_OF - struct device_node *root; + struct device_node *root __free(device_node) = of_find_node_by_path("/"); char *board_type; const char *tmp; - root = of_find_node_by_path("/"); if (!root) return NULL; - if (of_property_read_string_index(root, "compatible", 0, &tmp)) { - of_node_put(root); + if (of_property_read_string_index(root, "compatible", 0, &tmp)) return NULL; - } /* get rid of any '/' in the compatible string */ board_type = devm_kstrdup(dev, tmp, GFP_KERNEL); strreplace(board_type, '/', '-'); - of_node_put(root); return board_type; #else