From patchwork Mon Apr 8 06:59:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 1920662 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=aP1Qoe1T; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=RrOFYFXn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::103b; helo=mail-pj1-x103b.google.com; envelope-from=swupdate+bncbcl4hcw73qcbbtvlz2yamgqe4ucm6zq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-pj1-x103b.google.com (mail-pj1-x103b.google.com [IPv6:2607:f8b0:4864:20::103b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VCg1v3g6Mz1yY8 for ; Mon, 8 Apr 2024 16:59:30 +1000 (AEST) Received: by mail-pj1-x103b.google.com with SMTP id 98e67ed59e1d1-2a4f128896asf569239a91.1 for ; Sun, 07 Apr 2024 23:59:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712559567; cv=pass; d=google.com; s=arc-20160816; b=mf2DJzT9bI9H+p2ztRafd4w0gj2XPmVXHeix3tUUPurLrUJ2t6Do9Ix8diDTv2z5Cm gUkUjHqwEPOVj1buaPpVXq0Tl96dqzM0Ibtmgt+TrGE4QFldn3Olu3Q23QhI/T9k91UL Fzq29cR0E4Thhrvf73EBoa1hu6kND3YrgWpgVyJzjntL3cNZFWohLu/chmnIbQjzoMuc 5/QbVRkhXozqWYgbwsWV+KC6Fm5R15YoEVg8lwbB1V2J4oEBxdwuwkcaHHbNJ6e6qB5C jjEWu2bYCFm7pKRrO/a3NrHZXKW0gNRapLspr7Wb+LAL+CMrKNsZJwHIctfOQB9W+88t XUKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature:dkim-signature; bh=ZZUnixwI9e5VbESIpgPSN6fyWu8w+wl06JxDH0+M86I=; fh=K4jeHnPiT0QC31iaVj8eCV/KtIBpZMYUJQ/hMMpfcWI=; b=hQUkKz//VY1mvP4Q0zFUaIh0hgMToxouRVA309k7fZlPn8qR/fRmsWT7F82clY3ssM RCHUGAdVwU4xrcLYDL/Yf4tlGlnpZ0yUd0Typdy98Cf+XySgBXWIXc9rghlV3i+ywbcU XGbtI0Brt9jyunbxrWwcjEIysopNmtnGr8tTBRvCgl7vFaF1VUi0ItEICzWdxs7msrUz YnmCV5QeJ4qKmqOYzK/Lq70Tr7TX6Or/qMLkdh3UKVq1XvsjdS6MbhcvNtnj8JZdBIv+ Gza/L8zRZkceRvVSS53ecF3RbdxeFVwebC0BbrXTIRQNuJwrmUjspiDMZen8qznATi/6 86DA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gKuOzFGZ; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::134 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1712559567; x=1713164367; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=ZZUnixwI9e5VbESIpgPSN6fyWu8w+wl06JxDH0+M86I=; b=aP1Qoe1T7fGnadfadSICbCFkeqOw1OtTqBGYnAA33JmuBx4CfVR2qLdnk7+fioVaq1 q1PHIylMQNP/ERWkcgHyAgu2K4jZzOcyzXdCpcQiT+abmCJ7oiyYqP6ckL4vKCZdb4uR q/XvRNotUnEL/FVJNqX8b/z34R7kqjltPZRiU8hW9ILGzOFYocG+l2mPa/4OxHCtxnwu uPUEA6b41Kr9xQayRmOltv/hRSHTJ36DZUhscCmsKP/+eHgZtACpBS7FrSZiY5qFBmri Hd9muKfgWiy599FnIDArI57gpzn9UMgYKSxTzfQ34ayaqtiKbJpX7Bh0Y7vyk4RbdpUO xEQw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712559567; x=1713164367; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=ZZUnixwI9e5VbESIpgPSN6fyWu8w+wl06JxDH0+M86I=; b=RrOFYFXndI+z+BgbZbdYck0NhyaRpac0sSamZ/8r12+pd3urIUy86iLAg4DSrOI6QJ zjePv8AzfnmiPkSPIijCvHkMGV6mkNDn5zL3zZwynyGXC9bDM65rovWLZsF5e2swk8g/ DZ30F6Za3VfvOhKGQBIRn+ibo1mn6kDQuFyZZy0/V77LSYsycXKIIAwA8MYstDEsuL62 QukJwYJkavQD2kwSr47M1G0L5SYLROMRyrG4IbsoG4UQ1D+8lZ0m3Qq7hOR9cJ/B3rr9 eWf3VYZo3/2Fmo/HN+TvhNEpyNSya45ydkDewqzdCSxim8fODfvyEc2OkHkoHAKL4n80 6oAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712559567; x=1713164367; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=ZZUnixwI9e5VbESIpgPSN6fyWu8w+wl06JxDH0+M86I=; b=m9ThCpEXUhnOPv1JkYI27eKint3hElxAjxR9gMXfm061iUTw3i6f8a2LtZxamt1QrV HrowJ7IzSHFPwTLEz6g1iZPp2riX/FlqO0Iz56QoyQ4xf1n0FU58ZRqHl6r8ZyBAe1Np zeXrVQogHJlGC4uRVJEToayAE96dpqvKrenGOsbgUeNtA5ErS/PePy2xL/0s3U0VY2xh H7a+CDQqIFTj0u7SxqsEXXSJsEOqJT9JgZ9ZLxwmyOhEgEwDBwm7bDSLdI4pJFeHW4b0 hhUkXDbTXc+6OQSn+WQbX4HbFSvROiHlAxZllQ/5cMqwsx3qW7GjlryyuItQzL3cpUwV kIZA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCU5WaJ3kz0UNVBURIugsicaoCI9J1/lzxOBvGMUH+9XIlqDvJDV7CxsO11kj5AtdBnFc1vVnWebKPmtIWBdsFGAOAuzWqru9TEdCkbKJg== X-Gm-Message-State: AOJu0YwAtn29mLsi0W2S0ETkVIdGYmOWdzQg4bGBmcjSRcySib3iUiRa Dx7qIPs9Zb7+Ll/olpK0QXt3hEFaU4HENP8yJPOksA2GXaSjqlfx X-Google-Smtp-Source: AGHT+IEl+7orslM2s3yNaLMru7codcGNGXwi7vbzsdIF9Hd7uQ/aJbRmKsKCbNlIwypT3ifNqL+r6Q== X-Received: by 2002:a17:90b:4a0e:b0:2a5:f53:ba94 with SMTP id kk14-20020a17090b4a0e00b002a50f53ba94mr2484167pjb.24.1712559566635; Sun, 07 Apr 2024 23:59:26 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:90b:31ce:b0:2a4:aaeb:382a with SMTP id jv14-20020a17090b31ce00b002a4aaeb382als871102pjb.1.-pod-prod-00-us-canary; Sun, 07 Apr 2024 23:59:25 -0700 (PDT) X-Received: by 2002:a17:90a:d910:b0:2a1:64a:bb63 with SMTP id c16-20020a17090ad91000b002a1064abb63mr10217849pjv.2.1712559565002; Sun, 07 Apr 2024 23:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712559564; cv=none; d=google.com; s=arc-20160816; b=xM9L3R4/0CoR5nUX5S5FI3jplUmdpc7axbzBBpbS4H1c1sDEWNEbWbIr4r+V3pavYO 7U44MLT3on8yyHdhSSa89MBBL7y9NFtU5YG2L5EMviQPUxhmec8lhQ2m1LaocUId6SIz WcA8dvEaZHyyLpm0pJSlahFIX1q6JIWwOgno+qdT+QhmVVuTwFOQffPz4tFb7dVlv7pv EogCCNLrr3nhIH0V4LsBujWS3lLG6n0VNkLXUedtdWvUBT5PNPjYHx7JxjbJcf43qkbP /8L45qYCKqf/TLHMXBNFU2XHse7RDqSrEFasJnwWcWzEATf9M4G4uFeM91hmaRTweXcm 0M0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=sBvrRr4dkF95bu/hx78ZWgq+ncJdf9mzdAcPPHuUmu4=; fh=KPrAw848PoyEggiIX82ubXk7sJG2UD396EeWf1FQVUo=; b=EG9UvS90ScJ8uX5tnDrjLXpV3XGFPZp3rQZBexgfksOWGqZyAxdQ2C2gNZj2HvQQMn y2QYmDPNdzp2Fps2UxozZ8Gb0/QdV8w/W+5AZAHjhSnYBzLNkWnYF3iFQiQN6kOMB2Yw sJHfLboe+yVuu9IXzncetcr7qE1wHxTSWFtVyNehue4nm7jTMxLhlzlabb/eJoWmRpDJ 0C+gwi2t1v5VHxwwcrVDF/ml7N4VPFkgzC63VLw9pXx3riNTw6NuKjxkUE2i7xw8ziLy aDsuabqM0D2hN24hVeDWuJB4Hz5Z5x8bNP3Ln6WYcazsjg3vWpooeGwEg6VfXEq7W5Ck fCag==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gKuOzFGZ; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::134 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-il1-x134.google.com (mail-il1-x134.google.com. [2607:f8b0:4864:20::134]) by gmr-mx.google.com with ESMTPS id a4-20020a17090ad80400b002a303fa1b4esi1021970pjv.0.2024.04.07.23.59.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Apr 2024 23:59:24 -0700 (PDT) Received-SPF: pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::134 as permitted sender) client-ip=2607:f8b0:4864:20::134; Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-36a19fba840so3514225ab.0 for ; Sun, 07 Apr 2024 23:59:24 -0700 (PDT) X-Received: by 2002:a92:d145:0:b0:368:7571:686d with SMTP id t5-20020a92d145000000b003687571686dmr6442230ilg.1.1712559563764; Sun, 07 Apr 2024 23:59:23 -0700 (PDT) Received: from james-x399.localdomain (71-218-245-145.hlrn.qwest.net. [71.218.245.145]) by smtp.gmail.com with ESMTPSA id ay21-20020a056638411500b0047f222638b1sm2361234jab.124.2024.04.07.23.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 23:59:23 -0700 (PDT) From: James Hilliard To: swupdate@googlegroups.com Cc: James Hilliard Subject: [swupdate] [PATCH] mtd: handle ubi_attach race condition Date: Mon, 8 Apr 2024 00:59:13 -0600 Message-Id: <20240408065913.40798-1-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Original-Sender: james.hilliard1@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gKuOzFGZ; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::134 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , If ubi_attach was called while the attachment was already in progress we may get an EEXIST error. If this happens get the dev_num with mtd_num2ubi_dev and do not keep attempting to attach. Signed-off-by: James Hilliard --- corelib/mtd-interface.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/corelib/mtd-interface.c b/corelib/mtd-interface.c index 90fc6dc..c897968 100644 --- a/corelib/mtd-interface.c +++ b/corelib/mtd-interface.c @@ -379,6 +379,9 @@ static void scan_ubi_partitions(int mtd) do { err = ubi_attach(libubi, DEFAULT_CTRL_DEV, &mtd_info->req); if (err) { + /* Handle race condition where MTD was already being attached. */ + if (errno == EEXIST && !mtd_num2ubi_dev(libubi, mtd, &mtd_info->req.dev_num)) + break; if (mtd_info->has_ubi && !tryattach) { TRACE("cannot attach mtd%d ..try erasing", mtd); if (flash_erase(mtd)) {