Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp935693lqp; Thu, 23 May 2024 04:47:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbcmH9MfChEkEscPmnKD3W2VIrEbX49umS48n9VsHFiZ5d6QTqXCU18X0uYZ5yGR1Rj6W+1EG2lzo0D2YyJqBuLFj+9RIP6whT7kUxLg== X-Google-Smtp-Source: AGHT+IGHGcuO66vcsdshNQ5mIo4ft1vkYXJhTrBV5DopuHUgEBxHSi3aq187C0NiEJyuYkiqeu76 X-Received: by 2002:a05:6a20:1014:b0:1a7:bb6d:6589 with SMTP id adf61e73a8af0-1b1f88a7888mr4260475637.29.1716464871520; Thu, 23 May 2024 04:47:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716464871; cv=pass; d=google.com; s=arc-20160816; b=S/3ZNqK/rGM5sQyGbyuPDqflAaS6daGmFx/vORAuCTMK6Q2VbqRLsnmvs6SNkbJc1e Jf+QB7ARa/HLvlEYgpfD+JaNDDP8dXxttd4Jc7OcmVtudHcuc0YrI2NOun5xaldVNAam hIZpKdByCi964irT0ZxPMJ9eRqccw8GFITcBk2YL+ZG19+lvwZw+ELL7pkNkTESSkJbM 69T7t5dI9JF3NCec2aQjOcRj3FfKhxUuzBDNdpFxmw6iz1gL5Ov98LiWjQzuOviamPTo 7n6X40LsHcAoXXZd286QNoSYR2sf1P/iaGtfuMF+hcqD2ji8gf6O1UtWQYbs+VdDjpCt uU7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hsECkxPLFWKPz1muqOtYE1c7jEUGWA2sOzYY9LP+Vq4=; fh=O/bTNhn8EPfL1d+9hdDmuy3NpGdjkdf2/kbT3Jj2cMk=; b=SRZASui0bZdT4sSwUwe3puL0Ymmi7Ws2PRaTF0hDK6rXhbu30QSZcLkmevJG652p1B mGPygfJA2QoMtU7IkOMxAOoX3Jti/UMClzc4c6MwjCOQMTgSb9KGpJCdSi9n5jr/yEk2 2IA/nb7rNF2vZK1BXokjKw+rMOM7Hoqwo68a/USl0xwxMsUBdUo7G717AWEhgYniY4Bq 7Dxz8VfcbGH9JDTXccG+7E1fKwFS4kKDseAdkaPTCle/ps4q5qlzzvDcvzODkizgMQAW fNxeI3akqR2k6OKk0pGmnr2QYmKajmMG/7ak7oMSAYL2j27NSWLQGDPw7p5J1D1ZDLLS DPNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NMmYC3WZ; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-187414-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187414-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f3083e6ba0si62243455ad.450.2024.05.23.04.47.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 04:47:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187414-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=@linuxfoundation.org header.s=korg header.b=NMmYC3WZ; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-187414-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187414-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1BD25284479 for ; Thu, 23 May 2024 11:47:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACEC113BC05; Thu, 23 May 2024 11:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NMmYC3WZ" 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 CBCC53307B; Thu, 23 May 2024 11:47:44 +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=1716464864; cv=none; b=WlQWxvgjoX8D6iNN37flF+LoHUJHFtUMVk2VWgkgvVgqvM0nDz3Kz7w79rqts5q/vqzpU3OPfSo7zyVj8lJp+/gPWiH6+ycefUnn0/Svm2Aj83UNklam4qt/4SgFg16PEUn4M1MIDhUGVbPhn9HY+E2GC9pTFByAymizkF+cNL8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716464864; c=relaxed/simple; bh=3xbtnJwok+zrcbye3vysIdYFag8LyyseDL1qlml8khc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qIubNPDHFHKP+dN338Ws6GeTGiP43apyoskXmDKvEw/1mnTBLeaM70P9x8JD0xKbM8+qmaGgVqegpbf/SZvuaJRp+B3ftmvkWq1Cq8NPKmFLxesmiKVwchoYSyO7Vcb4VJn44gsHOEH5k6M06MfKBRneJIPR+MF1Wwg/JzZ8qNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NMmYC3WZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F219C3277B; Thu, 23 May 2024 11:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716464864; bh=3xbtnJwok+zrcbye3vysIdYFag8LyyseDL1qlml8khc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NMmYC3WZAWpmW6xYQmR70bKA5gQiFRjQyPCYC3hNWsRwhWemQneADLGWG0c/O7ZLq EtmwpAOJOpIC7h1ykeAIMpXpflbVEEijS4DXHeqym8XVN8Q9x/2MXiAzp6QYoq199R 3s7kWsSuLjpvRTOmBHpCnilH3S5zeBzaGchiW/oU= Date: Thu, 23 May 2024 13:47:42 +0200 From: Greg KH To: Shichao Lai Cc: stern@rowland.harvard.edu, oneukum@suse.com, 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: <2024052351-demote-gangly-74b0@gregkh> References: <20240523113410.983875-1-shichaorai@gmail.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240523113410.983875-1-shichaorai@gmail.com> On Thu, May 23, 2024 at 07:34:10PM +0800, Shichao Lai wrote: > Since uzonesize may be zero, so judgements for non-zero > are nessesary 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. > > 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..17c73acd3b02 100644 > --- a/drivers/usb/storage/alauda.c > +++ b/drivers/usb/storage/alauda.c > @@ -813,6 +813,8 @@ static int alauda_write_lba(struct us_data *us, u16 lba, > unsigned char ecc[3]; > int i, result; > unsigned int uzonesize = MEDIA_INFO(us).uzonesize; > + if (!uzonesize) > + return USB_STOR_TRANSPORT_ERROR; Check after the list of variables please, not in the middle of them. I think checkpatch will complain about this, right? > unsigned int zonesize = MEDIA_INFO(us).zonesize; > unsigned int pagesize = MEDIA_INFO(us).pagesize; > unsigned int blocksize = MEDIA_INFO(us).blocksize; > @@ -921,6 +923,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, > unsigned int blocksize = MEDIA_INFO(us).blocksize; > unsigned int pagesize = MEDIA_INFO(us).pagesize; > unsigned int uzonesize = MEDIA_INFO(us).uzonesize; > + if (!uzonesize) > + return USB_STOR_TRANSPORT_ERROR; Same here, at the end of the variable list please. thanks, greg k-h