From patchwork Sat Feb 10 10:53:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 199243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1403206dyd; Sat, 10 Feb 2024 02:54:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbVZnXr33pq4+JMK5ZE2GH5JtnmhmIBedWX11jkULHqAFcyq6wziDzohfUst8e/i7zUe6c X-Received: by 2002:a17:903:22c1:b0:1d9:8ac8:d784 with SMTP id y1-20020a17090322c100b001d98ac8d784mr2131902plg.7.1707562456768; Sat, 10 Feb 2024 02:54:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707562456; cv=pass; d=google.com; s=arc-20160816; b=mt1/utg7Qn5DjLxouIJ351YUZIZu6oCR9MK0+Az67B46dkCzWPXnDxqqSV52Pqczyl oQNiLnMvifUOPbzSX9/zH832VAG5mnhmVbMq5nom6/FFjWVMBF2EzykbqpVteJz5biZb DsFjnUC4U5Zuf0ZtcdgoLbGjI6AzZdyPHk3HWxjcoP2E83QdgWg1hQ+FsEss0S7JXFiG UHOAKkE9hWHTLBSLWZBnzbZkIaZM0KvEXAhKJiYRj0mfoda4ZZ6aiawiiKVVBrjs8is4 L58fP+E8VKui6MUjC0UP6i98Vl0T/TdI+pzaBGWSOF1dt1uAh0mOk+ibzWiuUrnAp8oh QMKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=7QYgDN3BJUEnPT+SJRI8j4ug6VUW8Hkqd9k+/x2jDfQ=; fh=BYhdBV81O7k4pDqnuuVcGAPWaH8T/hw9TAlcFxwGThY=; b=WSCjWet+tGIlER1p3ZrP4UtPXaQXfwJ6ZgqD0JYw/0+dygGtft8i7iYHWFlxNboXmY ptb3Y821XFKv3QYUf0KtNrW7jSofuDEW9MpLTPh/QGxrM5Wt8Cgttw9niAksjtnho2Mn pGGDhKPDPPH/d75Y/lRu7uKct55pz4OUNLGE2Zymoj7As2wUfysHE823Tv9lcpTZnQ2C y7B4w1vOth7bcsADInrXNX3XAKjOeno6ajZFeZtUYOpRyyIIPidZGAjlvTTKC6Z5cu96 p60zYePhB2TEbU5WZCsQfBqbwgdKbJKhCJqcUxnMWZ9D7Ix3t00rjC/BLkAfZAbtn95d HB7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=UveCnvEH; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-60366-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60366-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr X-Forwarded-Encrypted: i=2; AJvYcCUgeH4gijPdjiGFkLXKSbCGArpHtzo64l135JWcgpQObt/rj5A/hGsQMbS0zks5X3ojiSuFU27OpMi15SElkHPJ4AhMAg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ft19-20020a17090b0f9300b00295da5ef7dasi3196254pjb.110.2024.02.10.02.54.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 02:54:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60366-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=UveCnvEH; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-60366-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60366-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A0FC0B240C2 for ; Sat, 10 Feb 2024 10:54:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22BF6374F8; Sat, 10 Feb 2024 10:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="UveCnvEH" Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) (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 8D9E5364C4 for ; Sat, 10 Feb 2024 10:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707562426; cv=none; b=dJXkwGi3qO5//siWnfEjSvnowd7QfTZ++Q2M8e+ZUBRN8EgZoES/lYMZa81xfmEWXr5GLEEgOh94IHze4hUBcXLpxM7lIN4Gv3hB4MEGGQssWxqn+BXEj63dUDRJuFs/kagvc1PPkAAotrR2824XxOmu9Xyjk52qIQJzEtduasw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707562426; c=relaxed/simple; bh=ZNR0Ya2GtQ55/jW9CFZk6ueuv1ZGLDunwSJubLSmEUg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rpW6lMUCJAB8JWrf9b08k7KaO30cmvBO621gcV/0iuy+l5nmr+shR5w9rr7odITdcYfA6yQnnDiFiNPnHwoS/1K3eJ4op7h9OeinNfEYsuB2vffp1XyKLGwym1G8V89IvC/9lk05AK5DE1894lx1b5AL7g7dsVCBWbmzKlTGGow= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=UveCnvEH; arc=none smtp.client-ip=80.12.242.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from fedora.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id YkzGrWWZFCB5QYkzGrUBap; Sat, 10 Feb 2024 11:53:36 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1707562416; bh=7QYgDN3BJUEnPT+SJRI8j4ug6VUW8Hkqd9k+/x2jDfQ=; h=From:To:Cc:Subject:Date; b=UveCnvEHrvJuAAmeSuiaUhwqL3TLTowduXR5o9CGK3lhSCyJF+uEzXZgaNP3nfSWw 8yTxdu8msgcHsVkmmtZfscQHT6SVI2QUJEQOCv8o24MDL/up9c8pZCqvT0ZiArXL1S tf9VC1ooyex07pt8kLEbxGSIDqv0UOxeIl1wEyywldPXmCP6Z+5sYRqrS/tgLHnkIQ ILJBl7d/07JlGnFZugaxOySNwljPdC07VNS3raJ/81DFeMlpoumlobh0haMvkBtItp oEdcNSer7Kwd4oW4uv2Mm4iE8YuxPQs7No8OXVl3y3uKRbNKNYznQLuIeWtVh95sHL dEA60srFFusVA== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Feb 2024 11:53:36 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Or Gerlitz , Eli Cohen Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH net-next] net/mlx5: Use kasprintf() Date: Sat, 10 Feb 2024 11:53:13 +0100 Message-ID: <9bb8d927ec172df227f84694dfa5769623f48c89.1707562340.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790509010550542077 X-GMAIL-MSGID: 1790509010550542077 Use kasprintf() instead of open-coding it. This saves some lines of code, avoid a hard-coded magic number and is more robust. Signed-off-by: Christophe JAILLET Reviewed-by: Simon Horman --- If you consider it as a bug fix, should 'name' overflow because of the hard-coded limit, then: Fixes: ac6ea6e81a80 ("net/mlx5_core: Use private health thread for each device") --- drivers/net/ethernet/mellanox/mlx5/core/health.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index 8ff6dc9bc803..3f775da15afc 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c @@ -856,12 +856,11 @@ int mlx5_health_init(struct mlx5_core_dev *dev) mlx5_reporter_vnic_create(dev); health = &dev->priv.health; - name = kmalloc(64, GFP_KERNEL); + name = kasprintf(GFP_KERNEL, + "mlx5_health%s", dev_name(dev->device)); if (!name) goto out_err; - strcpy(name, "mlx5_health"); - strcat(name, dev_name(dev->device)); health->wq = create_singlethread_workqueue(name); kfree(name); if (!health->wq)