Received: by 2002:ac8:3b51:0:b0:3f3:9eb6:4eb6 with SMTP id r17csp1442626qtf; Fri, 16 Jun 2023 08:46:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7H1bY/23OMXT9COXJGJfaIlZTjZDQL/BXIf+3/RT/XCD8+qfKpDPebnDce7bsGcIB9GTss X-Received: by 2002:a05:6a20:8e07:b0:102:d2fa:d707 with SMTP id y7-20020a056a208e0700b00102d2fad707mr2853382pzj.52.1686930379062; Fri, 16 Jun 2023 08:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686930379; cv=none; d=google.com; s=arc-20160816; b=JpC8ZydrfuDlCR2H2Jf4tzfLZlh7fHbz/Ky2Gsa9MkZbBJw/1vjRpVdt5xA2K8zwF5 nCC/A5JCVgPpgyZO4izJyO0rW4IpoxvVIX7lzRuM74XeNPYn5DdNchyetMIQLRuCFRCj ldTrF2V9MNq9sxCf1T7a8/JlwLx+AujKxpRWgNPx0ZurAFvJX/Y+298xIUReR6qIn5ip KevXgxblcADUY3/LIPTgn8euZvlQDy4+0arn4Gy/J4tfghP5TwueM24ZZ9z9kGopj9Fb iChEQSOu1RVK8dRSwkajo56miMW98yxtGJeKfKpnGiTDyAPbNodotVWp4O9m52wklUyB 1Wcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TUdwy2/36hgEkTz9QJkYNZGHUYq2szwxedz8pSMdEEc=; b=VXEQSrqaNYwwlK3Jx777IuECPKU/0PA6H+EDWoOF9ZKVuU3OVDfICSJG55zQlePkh3 3r1YtcEvEobpxNYLgZ9gAZ9Ij8n76fsS09RH0AE+lUtVtrVTNgNt0+iSmyNM77lAiSbk vUmW84toMBvgM+k3Y2JK+jejM2ErgSuwVgTq/fOf04yuCqPY4uZ0uYnb3n+0oUEQqsoo Tj1wyKZ8/lcr+GszvCziUw1ijOQU9t5JPoL6oDQsNQ8qVeCd566PnOG577NXDDTCt2er Ed8gnzok94jY31VnRtJh59S1OYrcvXttji/umaKl4fYrM7IoAZ7+0JJE+tj9y/BB53GO bVAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="n80NvEX/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p5-20020aa79e85000000b00666887b7eecsi700866pfq.312.2023.06.16.08.46.06; Fri, 16 Jun 2023 08:46:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="n80NvEX/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1345969AbjFPP0N (ORCPT + 99 others); Fri, 16 Jun 2023 11:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345955AbjFPP0L (ORCPT ); Fri, 16 Jun 2023 11:26:11 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CE872948 for ; Fri, 16 Jun 2023 08:26:10 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1b5018cb4dcso5707205ad.2 for ; Fri, 16 Jun 2023 08:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686929170; x=1689521170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TUdwy2/36hgEkTz9QJkYNZGHUYq2szwxedz8pSMdEEc=; b=n80NvEX/NzO2un18OWbPTOcYy0kouVcPki0WsS/d1yCArFZjQKB8cXvLE+Rb3GCB/H fTdgmhCzUJ4VM4raCRG8Sxx/SEUmYmCllGtk9HPOZe1H3uFt2DNpaJcuytR28HCOZGEx 1t3GcY8XpXSZU4hqfWt+T7OkEXIrtMQVmc9NcZIhrtgS6SC2H0KfB1x2AlDL0sGN4Ut7 psB5S0KnDvOAtcNttjgWLDyHv8qzXZB1DPUe7KZRkH8reQGEttf5QD1nIYwmePtDsNAu t28HTDhWIOK4+S7YAq+cccetIYra3Yir4sXU5E6dOWTTwiHCboZXzfPv9wwWLeW8yCk+ y/3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686929170; x=1689521170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TUdwy2/36hgEkTz9QJkYNZGHUYq2szwxedz8pSMdEEc=; b=b73bpjjIi29RpuzMEF6YUhg6X0UfAPoJ675XKzDtbhKcyJ9Jn+gIcshrSHA+tEdFJv vQTlSlhppHDKiPaQvaQ3ZNTAQx9iCKxa4qpejbqA6mVgCHf2wZlpEbtCFzx8+Kvu2un/ xdWCDv/CMhAbpHoWUrvi+VnK5O3kJfV7B/QzoF0UlfscowxPItAD/EmFJUNQqBiezTSD L/tCN+Uk9us43dDGDqUxyOwrBeHWh1V7tkNIN9A6vsa8tzu3mP7uZ+tSZK6MENcgOmS+ scoErWyufddcjh1ZjrdvEWmc++KUOov3m847MCgSch24DoU/1SvTbRxdVzdi0nzO1vQr eraA== X-Gm-Message-State: AC+VfDxnV9J0hmeYA2BwUFmuzzlcOzmB+IGc9N6pOuS9dSoNnH9Xk5W2 c/0Eke5NCxhT9fmeaQCTOcw= X-Received: by 2002:a17:902:bb96:b0:1ac:8837:de9 with SMTP id m22-20020a170902bb9600b001ac88370de9mr1716854pls.3.1686929169864; Fri, 16 Jun 2023 08:26:09 -0700 (PDT) Received: from redkillpc.. ([49.207.203.99]) by smtp.gmail.com with ESMTPSA id y13-20020a17090322cd00b001a69dfd918dsm15992057plg.187.2023.06.16.08.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jun 2023 08:26:08 -0700 (PDT) From: Prathu Baronia To: prathubaronia2011@gmail.com, Greg Kroah-Hartman , "Fabio M. De Francesco" , Khadija Kamran , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Cc: dan.carpenter@linaro.org, error27@gmail.com, lkp@intel.com, oe-kbuild-all@lists.linux.dev, oe-kbuild@lists.linux.dev Subject: [PATCH v5 1/2] axis-fifo: use devm_kasprintf() for allocating formatted strings Date: Fri, 16 Jun 2023 20:55:59 +0530 Message-Id: <20230616152602.33232-1-prathubaronia2011@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In various places, string buffers of a fixed size are allocated, and filled using snprintf() with the same fixed size, which is error-prone. Replace this by calling devm_kasprintf() instead, which always uses the appropriate size. Allocate the device name with a unique identifier instead of a kernel address. Signed-off-by: Prathu Baronia --- V4 -> V5: Remove the dev_info() and use a unique identifier for dev name V3 -> V4: Split into warning fixing and cleanup commits V2 -> V3: Fix smatch warnings from kernel test robot V1 -> V2: Split into logical commits and fix commit message drivers/staging/axis-fifo/axis-fifo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index 7a21f2423204..5e070e00e27a 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -816,10 +816,6 @@ static int axis_fifo_probe(struct platform_device *pdev) * ---------------------------- */ - device_name = devm_kzalloc(dev, 32, GFP_KERNEL); - if (!device_name) - return -ENOMEM; - /* allocate device wrapper memory */ fifo = devm_kzalloc(dev, sizeof(*fifo), GFP_KERNEL); if (!fifo) @@ -857,7 +853,11 @@ static int axis_fifo_probe(struct platform_device *pdev) dev_dbg(fifo->dt_device, "remapped memory to 0x%p\n", fifo->base_addr); /* create unique device name */ - snprintf(device_name, 32, "%s_%pa", DRIVER_NAME, &r_mem->start); + device_name = devm_kasprintf(dev, GFP_KERNEL, "%s_%d", DRIVER_NAME, pdev->id); + if (!device_name) { + rc = -ENOMEM; + goto err_initial; + } dev_dbg(fifo->dt_device, "device name [%s]\n", device_name); /* ---------------------------- base-commit: fb054096aea0576f0c0a61c598e5e9676443ee86 -- 2.34.1