Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp967532lqp; Thu, 23 May 2024 05:42:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTtYJq0Saf63dIWUXePqUPJhVqqe2zbjqUxBA1qiqX55iYri1ThHi5+Qc4Hum6MBTVIowDjG6k1BV6I/2UpzB1Zt9CK/d/CgkRMhFeiA== X-Google-Smtp-Source: AGHT+IEf9DCWV7tK5WSh1sbmpAsxGeZyckrf87Oxv63lSaAqe7TDA66IWFXqR/5Hua3ec1jYBiKj X-Received: by 2002:a50:9e67:0:b0:572:a76e:645a with SMTP id 4fb4d7f45d1cf-57832a27e71mr3108006a12.12.1716468177321; Thu, 23 May 2024 05:42:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716468177; cv=pass; d=google.com; s=arc-20160816; b=EPIpM2Jj2taJWYC5MnKBx3TtBB894JvyiVisZWKg2NQjsV/7B/mxyV2GrEATxR2W2P WuKl7b3wmjFvX4G03cKL9Ma8YDTNU8CFYzweqDu60VGLyXWHtW29BwMbgueHYzegH0lg 01NJEgbWo2gTXa0VM4xr/zU5F98UOQ25Z8Ck4U4NGRjWIieTqjp9W+aXDOdqFW3z+I38 GJokz1taZi9cOul3i3xv97fPaCwZh+uGd6yIPqPPEAjrMTrZUiZxlOe8UbHU6Ko8/P/A PSANvUMX/iyuEbOQ05lw5D41jkU5/W6+QFJ3B+N8o3uy64il/ZkfP6s7YpO8RWJ9VoKG QfGw== 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=JbQU7x0E7jnDIOH/Jd+2ktPiOpulnhjgxogsGpGe1YM=; fh=veZnRy6NZRyaIG5DmCc53NTOkUJ3jeFKnd3tlRsyK8c=; b=MdWfgr0UQiZQG0MBt+GGA7Ha6WT5JCYQMDwrx79kHQA3sP4i25NANYOkmM0pPgR95Q T9ATWg4WMKGbQvgAkkoKw0ZXg6IsllXS3qifCeQ53bZKosXlKKUYQrobolzeg5bj2mcN keOGMyKLOZkB0dkjJhXYGfy+mHTLnrHe/rPd3Q/usw9T6aqxQtWwb3Jepz2VdZjZhMyY r09hhQHNgxzMeuTjW0udmnNaFFcREqEiVHCHD9SMfWUQ0Ni6TlWiMyDizIBqPAUVDi4E xCXpZCzcsolFLXM1rdcAhyBv4atnrBTQsC1RaprPPE6jN/kv4RaxZfM5jj4m8sndiCQY 92+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="MMFxKz/d"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-187486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c2d5e86si16871330a12.232.2024.05.23.05.42.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 05:42:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="MMFxKz/d"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-187486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 110151F21117 for ; Thu, 23 May 2024 12:42:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFE97149E06; Thu, 23 May 2024 12:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MMFxKz/d" Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 C5BC6149C60; Thu, 23 May 2024 12:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716468159; cv=none; b=O1238CzgD4M2UY/brwAzDZNgun53wyEQHtXzlmlTzAXjb3XtAij0LXLb5rDgxjaHJwYCmpI7Ci8YxKuJRmJq0f1kWGMpx2mRcK8ebaPzwnvlAMPAB3F/XjBEYq4X3i4Gr/PwVBnFOjrEwXH/JtFh63jCqH+NJtubaxf7qSP4pcY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716468159; c=relaxed/simple; bh=Esn6qQ80MM0mLfU5d1BTrg+JdFQ+xC7owVO0xXFpm5g=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=pHVy4UgsNcwGRT57PMeqBoFtwcmkl3nuDknCLB9PDpSi0K6YGgB2vj57oTMCFVNMrf/bPbtws+IzSYmK3oFvC7mEBrV3hxRAYEG9RhMHw74YTpV7/lhrAkjYaxgTilxjqQBFpp5ofyB+SOaqznxIuxpP9BGvbFQo26MktKC3yjk= 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=MMFxKz/d; arc=none smtp.client-ip=209.85.214.172 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 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1f3421564d2so3733685ad.1; Thu, 23 May 2024 05:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716468157; x=1717072957; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JbQU7x0E7jnDIOH/Jd+2ktPiOpulnhjgxogsGpGe1YM=; b=MMFxKz/dE1eB4dveiEfY66N0Ee/0xDGJA15ij0boUttVZ/qbiIAnp6ycmtd4KYZo3b 6oHF02DYEzYsMYANe8ElMkNAmXOINDXUHl/iR0idp7eUooZW1X3ZfNQode0XB4el3d7v LZmR/DGNqTaGsyp5c+MmKRUV52gY92ReOzWRNfVwegAuU+PTJK91CTJXiDoRsEjK8vHx rgSALMstVI1FJcGNjD8F44O4QioOVsYQiqf2wtRZLgKbGJynuWnrMmFbvPD1dFM2nw16 CfpEsiaLatuKmIpQItFs7RfMfxYD088nXBXOO+156v1yIG+fqns8qSXPpo7Gf5CCVVGW IH3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716468157; x=1717072957; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JbQU7x0E7jnDIOH/Jd+2ktPiOpulnhjgxogsGpGe1YM=; b=YSaeVtdvbZsvR4dJXEPjkL8xu4sqY7mTH5kM+HOwLMNehEjHR2youy04ERfhQY7cCo gmTIgiOtHCLsLc7vMie0Pqc/CbYGLfkEPdefu8g5AqN6a1lb0Tw6fcXdUJnA61XBPor3 JdhZv0ZjUGKpjmKhsO1SSys8FRMIILQSor8U2xqXUEcNdpdAr9MQFLow+CdQJwcKstUZ cNL7PL4CxrSJD9r9PGXyzNAJs8v76KRMOhjld5sclvRviY5LviIcLSe6FdD/RM3QDbdZ k54+ef8FWNWP5P+/BThSeHGDgBvqVmgZyJhEbeokH0TX/JEWZh652gUYDhb0f+OlRGuo r4tw== X-Forwarded-Encrypted: i=1; AJvYcCVwwry0ttZNrj1J3t1Qik02h4w9Xkcn/4TyrepPLKSfZCAJGsiw5xrwg9aPXgYRoBS3QaohRS39enAHCSesyCgYZe10P+nMPw3UonS+ X-Gm-Message-State: AOJu0YwPqaPkjjNerWAFWWLuqa69efPCS+n94ttcxShI5s3xJJPyy3mz cGiKHwGML+UU7Bz31I+tFv4A7duHhQUfdMel0Cr8M2o1OT9YgUvp X-Received: by 2002:a17:902:f550:b0:1f2:f9c1:770b with SMTP id d9443c01a7336-1f339f0bc9amr34931695ad.15.1716468156978; Thu, 23 May 2024 05:42:36 -0700 (PDT) Received: from velvet.. ([111.42.148.111]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0b1b1d13sm255739035ad.0.2024.05.23.05.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 05:42:36 -0700 (PDT) From: Shichao Lai To: stern@rowland.harvard.edu, gregkh@linuxfoundation.org, oneukum@suse.com Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, Shichao Lai , xingwei lee , yue sun Subject: [PATCH v3] usb-storage: Check whether divisors are non-zero Date: Thu, 23 May 2024 20:42:23 +0800 Message-Id: <20240523124223.1035964-1-shichaorai@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Since uzonesize may be zero, so checks for non-zero are necessary in two places of alauda.c. Reported-by: xingwei lee Reported-by: yue sun Signed-off-by: Shichao Lai --- Changes since v1: - Add one more check in alauda_write_lba(). - Move check ahead of loop in alauda_read_data(). - Change the order of variable list in alauda_write_lba(). drivers/usb/storage/alauda.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 115f05a6201a..ebef1a8a7ca4 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c @@ -816,8 +816,10 @@ static int alauda_write_lba(struct us_data *us, u16 lba, unsigned int zonesize = MEDIA_INFO(us).zonesize; unsigned int pagesize = MEDIA_INFO(us).pagesize; unsigned int blocksize = MEDIA_INFO(us).blocksize; - unsigned int lba_offset = lba % uzonesize; unsigned int new_pba_offset; + if (!uzonesize) + return USB_STOR_TRANSPORT_ERROR; + unsigned int lba_offset = lba % uzonesize; unsigned int zone = lba / uzonesize; alauda_ensure_map_for_zone(us, zone); @@ -923,6 +925,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, unsigned int uzonesize = MEDIA_INFO(us).uzonesize; struct scatterlist *sg; int result; + if (!uzonesize) + return USB_STOR_TRANSPORT_ERROR; /* * Since we only read in one block at a time, we have to create -- 2.34.1