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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF98EC54EBC for ; Sun, 8 Jan 2023 02:59:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CFD1A85620; Sun, 8 Jan 2023 03:55:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="MVAYZXD9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7EFD485620; Sun, 8 Jan 2023 03:55:26 +0100 (CET) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F302D85620 for ; Sun, 8 Jan 2023 03:51:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2f.google.com with SMTP id r72so2948998iod.5 for ; Sat, 07 Jan 2023 18:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=rDgJfXW0Y9vFY4aTcBJL50zTXxunXNYyhh6+WffGKDI=; b=MVAYZXD99wFSirJbUWp6x0/IV5JKKkoEennbYYJSEgovJvXUCRz2ZzprOSN49Pzyl3 tZJ2lZmfQCB4lmTIcrPnOZ+FExTrRDAw4b1vbUZ2u+C/modhNi1xPd8PWlxpYoENnIY2 /qBHcRvOonOAzf5qPdIgly/QJZAGre4D9I+a8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=rDgJfXW0Y9vFY4aTcBJL50zTXxunXNYyhh6+WffGKDI=; b=4vUnMABVWNVJNPIIrQkW8UAHSmtyoNdG9iRlvlo2tO+VniuAhVaWpHDTrL+1vzP5AP xplYFgMtRajwialWaQ5H+zZI87/OveOb4BjHWEnb3sHeuLCcAE+aD2nUyLCL/q5Sydhe FdM0AV0VfhSWcjo/jTLYWLGAU5Hm2rWAbmEjv12sOG3bPkpT8Cl4wWTHRjSplqOSGOt0 Z5izcgVhuOSrBLcDRZBpR50HDFcx6z9uIZY8TeTJWj6Oi0OxKgUPydbyPOjBbEV2dUWN 82ANeG/lPWLEVdSyNSXh7xSoWcpl2KNXL3A/WculeW3dGpQDBxk//30aN855ix+fCj/W /ttA== X-Gm-Message-State: AFqh2kpCaTjP6+bN8chq02cwUxdSH5plSKXUynliPTxQuJbr18LTzwf/ 1zrUOFCMlRWQtg76wBOzrUIKRo4gGwlUhI9l X-Google-Smtp-Source: AMrXdXvtAL1SU7maO9zxi2Phj5pOSdGC7a+YmaMiygFmVlQqOBA7VNGdQRMh3dPj6AyYzDQUAi/yEQ== X-Received: by 2002:a6b:7519:0:b0:6e9:b3cc:f1a with SMTP id l25-20020a6b7519000000b006e9b3cc0f1amr40031294ioh.8.1673146281362; Sat, 07 Jan 2023 18:51:21 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id c17-20020a92bd11000000b00302a00aaefasm1622174ile.26.2023.01.07.18.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 18:51:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Rob Herring Subject: [PATCH v2 34/71] scsi: Correct allocation of block-device name Date: Sat, 7 Jan 2023 19:50:10 -0700 Message-Id: <20230108025047.522240-35-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230108025047.522240-1-sjg@chromium.org> References: <20230108025047.522240-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This should be allocated so that it does not go out of scope. Fix this and set the log category while we are here. Signed-off-by: Simon Glass --- (no changes since v1) drivers/scsi/scsi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 3e769b0843f..6419f4be210 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -4,6 +4,8 @@ * Denis Peter, MPL AG Switzerland */ +#define LOG_CATEGORY UCLASS_SCSI + #include #include #include @@ -558,7 +560,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) struct udevice *bdev; struct blk_desc bd; struct blk_desc *bdesc; - char str[10]; + char str[10], *name; /* * detect the scsi driver to get information about its geometry (block @@ -574,12 +576,16 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) * block devices created */ snprintf(str, sizeof(str), "id%dlun%d", id, lun); - ret = blk_create_devicef(dev, "scsi_blk", str, UCLASS_SCSI, -1, + name = strdup(str); + if (!name) + return log_msg_ret("nam", -ENOMEM); + ret = blk_create_devicef(dev, "scsi_blk", name, UCLASS_SCSI, -1, bd.blksz, bd.lba, &bdev); if (ret) { debug("Can't create device\n"); return ret; } + device_set_name_alloced(bdev); bdesc = dev_get_uclass_plat(bdev); bdesc->target = id; -- 2.39.0.314.g84b9a713c41-goog