Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp964906lqp; Thu, 23 May 2024 05:37:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVssvQy7k1WhKTkTRdqRuSKorXNZonfhl1Zk/oy29Og+jRA5D1YpeG4bFaB//p9mxLJTJzIcyLo6tAClb0kYDwGHa7GmILaTxMfG4JL0Q== X-Google-Smtp-Source: AGHT+IGKHPRRGCnoe49RhZgwlGzZPIKdbUxqALdWUZ2uYHxySThNmESNI572Mb+Cu5vp39UxrSLi X-Received: by 2002:a17:90a:ee8f:b0:2ba:a1d:5a73 with SMTP id 98e67ed59e1d1-2bd9f493c01mr4815155a91.22.1716467854893; Thu, 23 May 2024 05:37:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716467854; cv=pass; d=google.com; s=arc-20160816; b=MSzz9kEheecIbmxQTiVfU+zdWad3GkUhbhCRl63iXzCkNNI36wzGjU7UuNiyG4N7X2 KTJni7T1piCzdCXMkn68t5otZ/1RxZQn+ZGXAsFvqTiGlNq4mOiq6wIooOx9qUP1UJ1Q 8lpgR0Z7+YlYHZaO4DP6EUFv96jdTw+azcnkM1YEjhtjpIl1WYF8fl8OTEeOthfrqz0V nYGwNZWujasXPvIydmHkyJKJ4dH7LB82hpwLkedo8F8umfliCshd2aIlbDWzM2MDujQd gbrehWU16syItpz8mjJ8zuihy4lBR/JxC4TYASyGuGIa0T2CvIn8e25taeXyRVOCshCw tygg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+Z+76Zjf1MMqUEDjvv9RqlpTJW6mr9cbNbPJ0OSNGKA=; fh=MNyjG2TuEBZmmkieg/sH1SELA4sUEBqf6v/R6fxeyGs=; b=lvC2UiM+46KqbTSnyMwAPfbLDvPbXDxTBLjjLGQUmrJlJbBRCfnspySo4AjyVCKkaR d4tjJuywgInh+D2Bbib4DjcDvThccEJchKufMun/blRxmaEWMi0/1gFXScSN8A4q7+re ioD7Ssw6+9EjnLsTgq4SSz9OSlv6i7FHOYKt3eB6HNbcn8pecICjsvE0BZTPrx4lDiqL GeCAsZPeDd/JFxcXc+S4fhaDDjtTLa5wgeYI9mNKxV8hzuV1qUh93L6ZO+iPFvQ3YJLU OsAeCrAF3xQambLK90b9fKf0/z/FtzaYlbsEerTsINpdTjjhjpTC00oRWISok0C+dRq0 LcQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KcGE+YTA; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-187480-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187480-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bdd9ee6364si1493107a91.9.2024.05.23.05.37.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 05:37:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187480-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KcGE+YTA; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-187480-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187480-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8C170B211F1 for ; Thu, 23 May 2024 12:37:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 115A7148839; Thu, 23 May 2024 12:37:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KcGE+YTA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 307E314532F; Thu, 23 May 2024 12:37:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716467841; cv=none; b=S4fMVWAsXA8OyuIoegjMynLaJixQnIYM/8QSNi4QI1dRyYTl8NSxVA9jifSXLqlwig6rb2+7BgQZP5ifcieS22aemiSSR3Zy8VzQkPlCd8dM/njKULisvn91DUPvj9Yo5AqXL9OO4///TunKOTaAOg5LTxF9Jy7g+F8FjN/uKeA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716467841; c=relaxed/simple; bh=o+cIsFagOQT2Q33MTrnnLdxWh5QXIRSFcQAPjiLDD0E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UzdDESExPY4S4RtqG6tbnGwJiCdC+/Hz3G7Lv9o7MS6heRzS8Lc85e413ztpzoLOGofZbs1PQOHsQ+YNpkYpRVy5OgShM91S0arCBwPUDMi8MEd/TTC7eRarD2gjC6d25x/eK1LEv2zzylQ1PXsbJnDrbc2NvKo0LfKfXuuOFao= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KcGE+YTA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B9ECC2BD10; Thu, 23 May 2024 12:37:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716467840; bh=o+cIsFagOQT2Q33MTrnnLdxWh5QXIRSFcQAPjiLDD0E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KcGE+YTAH4DiNSX1KL56t0ozxuwvELpqo4VkZZaTeDQBO44KZfSn0Q979gtVmbVFB NX73obibt80jeLyvLB7MieFgC+hOKMDeVdIEPZd6OKaC8T2G18B9m4/nutHTNsjLy8 12xmviuwtED6AiOFESaXpBnHJmPScUqT6uI5hUCk= Date: Thu, 23 May 2024 14:37:18 +0200 From: Greg KH To: shichao lai Cc: oneukum@suse.com, stern@rowland.harvard.edu, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, xingwei lee , yue sun Subject: Re: [PATCH v2] usb-storage: Check whether divisor is non-zero before division Message-ID: <2024052354-snorkel-drainer-d328@gregkh> References: <20240523113410.983875-1-shichaorai@gmail.com> <2024052351-demote-gangly-74b0@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, May 23, 2024 at 08:23:57PM +0800, shichao lai wrote: > On Thu, May 23, 2024 at 7:47 PM Greg KH wrote: > > > > On Thu, May 23, 2024 at 07:34:10PM +0800, Shichao Lai wrote: > > > Since uzonesize may be zero, so judgements for non-zero > > > are necessary in both place. > > > > > > Changes since v1: > > > - Add one more check in alauda_write_lba(). > > > - Move check ahead of loop in alauda_read_data(). > > > > Nit, this changes list should go below the --- line, as the > > documentation asks for. > > Sorry for my inexperience. I have read the document and found some > examples but I am still a little confused about this. > I guess this is what you mean? > > Since uzonesize may be zero ... (context) > > 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(). Yes. > > drivers/usb/storage/alauda.c | 4 ++++ > 1 file changed, 4 insertions(+) > ... > > > > > Check after the list of variables please, not in the middle of them. I > > think checkpatch will complain about this, right? > > In fact this script doesn't warn about these problems, but I will > adjust my code style later. > But the check in alauda_write_lba() is due to some variable like > lba_offset and zone will perform modulo and divide operations, > which may throw divide errors when uzonesize is 0. > So I think I prefer to adjust the order of the variable list later. > Changes like this. > ```c > unsigned int uzonesize = MEDIA_INFO(us).uzonesize; > unsigned int zonesize = MEDIA_INFO(us).zonesize; > unsigned int pagesize = MEDIA_INFO(us).pagesize; > unsigned int blocksize = MEDIA_INFO(us).blocksize; > unsigned int new_pba_offset; > if (!uzonesize) > return USB_STOR_TRANSPORT_ERROR; > unsigned int lba_offset = lba % uzonesize; > unsigned int zone = lba / uzonesize; > ``` > If it's ok, I will post the patch v3 soon. That works, thanks! greg k-h