Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp869774lqp; Thu, 23 May 2024 02:29:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXngcw6uWg61kNdnXlJcXNMr7nB4NCPS8rhDYadUdDCcYOnqMt43VrGBi0qMIwSCndhNGyTlVoWuS3uj/SEQppKALr+/sKONsOr/0rQ7w== X-Google-Smtp-Source: AGHT+IEPsU07FBVNOGchfpGjWXGtfaWwJ07rPdATPLGpN8R4TJhkFlwg91H+kkU6f/asbKb8FM5j X-Received: by 2002:a05:6a20:4313:b0:1b0:1ce0:1a39 with SMTP id adf61e73a8af0-1b205c8afdfmr2550308637.11.1716456548699; Thu, 23 May 2024 02:29:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716456548; cv=pass; d=google.com; s=arc-20160816; b=ypmV1e8KB2+cMpEzkqJY7BTdhXhuPQTfuC3iBNYbY24+Ym1KDcXoysBYx27nU3BeMV imio4CNulHQiO2rcmW+/M/cdxtKn3jA+/i7jXfccxSuXG09dGmyGZrlLUMAjNeVSJw4B VaCwgSPOr/HVc/y2TRWGITrybrUJk/qYGy4SDF9sMcHSWV8DTt4IuKiWTajYThhNgGRk NMhLXtezv9FkDxhjTI4u22UoPd+tGlE0mUtuZmVT7T7zJzSnzHyoVngPmsSnNEBcCxia Ll/2WanMTOyR4XZpx9EKxMhx2cSfRgQk+ukPtFy6ffZHxBaOj73fBEc5662mAM8Hnoti 4O5g== 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=LgjVFtFKjSQKkqo/YluY+yPsMkYZspFKPmE22dhDd8w=; fh=CjxzEPF4F79+m8CVUCwj+QaOyGGyGoyWbANyRLUBQDs=; b=Hqaqqg1xiduwI4/vIdfDOmW85nxFO2FIBoMfVJSrh14p8pUeNP+yDYr+QoCQM8obya lbMyib1oZ/yM9uJIIuGDgeAR9WdmHjzbaJNYv5jgGY1MDA9axXpmgyNLEysGhLruOwBr SQ1EUw6xSWLUcVfNjPDFKwhsStOYyjXrWjlOYMNztm62kDZ+wpVVgTO96vJGunvR5Ppb DdOgBCWjpCXMQBp8PwJEtOD9nkWr156t9yFMTIWAA/sKq18cYfW+mHgrjMcnf5RBvIx3 xCBszmRHZ/f22yzSxM/JThLuiOyAxV0JzMG2nX+BSIxb0hKpeFDCpYo989ioHKAWTGLu f2Aw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QP8i+FK+; 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-187262-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-65c6bba5346si12078084a12.746.2024.05.23.02.29.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 02:29:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187262-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QP8i+FK+; 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-187262-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187262-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6B05E284A6C for ; Thu, 23 May 2024 09:26:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29CAD13C914; Thu, 23 May 2024 09:26:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QP8i+FK+" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 101EA4F8BB; Thu, 23 May 2024 09:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716456404; cv=none; b=sNksetEOD5TiF0HmZ35AeJ3PGEyR8S+hCPkbutw52MwSQRMxGGdKpu2YjqUI6o+ATx9FmBtxWnPeJb1VW+ICKsBKeYsKlSx9wAkdhnLS+5fVWFZnlLRUjnzetBUSqXasd+IYDpgi61llt/DugBHB6MMqGlNkGb30yfGJInphTwY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716456404; c=relaxed/simple; bh=U4/f+5/ELJS3ohNly/5cYQy9ZMzgntrMLXVYhWvpTHQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=dAtHmbqNDC/um+Qt8KwCCkGseJ9IZO9zucwRsqzSnFUAg7HL5pMNVnuOEzr83jaWaH5zrKUVeBEoPCptGhpjz7rxwMCmKdzyhTLGq4bs9Yeneu0qE7+wIkO64GQBv69YiS3PM8NOCYVZ9fgCPWYPoWkehoyjv6QJUddUI4h3mg8= 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=QP8i+FK+; arc=none smtp.client-ip=209.85.214.174 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-f174.google.com with SMTP id d9443c01a7336-1f304533064so13237605ad.0; Thu, 23 May 2024 02:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716456402; x=1717061202; 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=LgjVFtFKjSQKkqo/YluY+yPsMkYZspFKPmE22dhDd8w=; b=QP8i+FK+TfArNsWta+I4FDNs4EQzlQ0MDoblMWJRxe9AzhbOfClzPo30NQueUcFr1s Czc97wcv2JMxxOt6mUFf3rRIkIttWwzHnH0Lgbm5Rdkz40ygxfOU2CUR9m51RegQ41EX 6c71KUT5WpmTv7j+WE/05mJYqH9MqjpQDkLk+Emb3eOVLZrPdqKWF+SpqIuEq/p7wd6C VQ6WjlhUwHMe4s/vpEmyk2Kdyneyt14IX5aJk+j9BqbrfjeAyjATLzGfd4TSK6oovIAL nqt1BTZwnRw1X/SSigcItr7cOhYF5AOkMFJ8R+QI+m0v2sAt6JkB5mlfcqkstZx/sP/H jngA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716456402; x=1717061202; 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=LgjVFtFKjSQKkqo/YluY+yPsMkYZspFKPmE22dhDd8w=; b=SLwt5BIChTnIQXw5GCAqvGeTukG3IBqvfJ4dztQu95nn+3wqEPnI/YFM0skJHY+FRC nZwkCGkOSHws7WzaCU3X/GOrF7U8CM5AygmJyL0jiXgnsYD8XiaTQ9OZLLERwPVQVZpU VgJCR9n+qZtPVX+fubBdOjyY+UywyNTcDeJEeZVjQrqPAb/Qo7ogeYuTlyvbZAQ2GwHa bJoiVrmaoL3TkvNPQ+5fZnOVdGU6WVLGc/vKOTLwgOcZYLdj3E49cs6gWIHJudRkeH5W DALcJo9rqJnZ6ZthJu12Oshw3ASg6j9POoff8JcABazn+KwjO16W8JhhME+Q0JwfkLCA nOkw== X-Forwarded-Encrypted: i=1; AJvYcCXHpzkgukl7j/YJ/SxGzC8kTlUwv6cT2icn1rILDJqgB6lnMJlDJ6xirDb2gjk4E05w6T8WBsdjqCgzy0XQixACaetqDLe3CnDyWQxI X-Gm-Message-State: AOJu0Yz0AVGIQd7Jz+SBjDhp4YmmSPJcriKNAgRKG0W07sI9t4fQPzvR 7owtSR05NPDVpc4Be0O/alBsExBCqXD/keVaafGja5rNKkTfMZ5W X-Received: by 2002:a17:903:11c5:b0:1f2:f50d:ca47 with SMTP id d9443c01a7336-1f339ef5237mr23830825ad.3.1716456402245; Thu, 23 May 2024 02:26:42 -0700 (PDT) Received: from velvet.. ([111.42.148.111]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2a6641dsm23591883b3a.4.2024.05.23.02.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 02:26:41 -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: [PATCHv2] Check whether divisor is non-zero before division Date: Thu, 23 May 2024 17:26:08 +0800 Message-Id: <20240523092608.874986-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 judgements for non-zero are nessesary in both place. Previous check is moved out of loop, and one more check is added in alauda_write_lba. Reported-by: xingwei lee Reported-by: yue sun Signed-off-by: Shichao Lai --- drivers/usb/storage/alauda.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 115f05a6201a..a6e60ef5cb0d 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c @@ -818,6 +818,8 @@ static int alauda_write_lba(struct us_data *us, u16 lba, 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 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