From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AF2D6B6F69 for ; Mon, 5 Dec 2011 10:18:33 +1100 (EST) Message-ID: <1323040701.11728.27.camel@pasglop> Subject: Re: [PATCH 1/1] Punch a hole in /dev/mem for librtas From: Benjamin Herrenschmidt To: Segher Boessenkool Date: Mon, 05 Dec 2011 10:18:21 +1100 In-Reply-To: <144CAEA6-C129-4935-B6D1-A7D6F24530A5@kernel.crashing.org> References: <20111202222623.GA31354@us.ibm.com> <144CAEA6-C129-4935-B6D1-A7D6F24530A5@kernel.crashing.org> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Cc: linuxppc-dev@ozlabs.org, sbest@us.ibm.com, Sukadev Bhattiprolu , paulus@samba.org, anton@samba.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Sat, 2011-12-03 at 04:22 +0100, Segher Boessenkool wrote: > > +static inline int page_is_rtas_user_buf(unsigned long pfn) > > +{ > > + unsigned long paddr = (pfn << PAGE_SHIFT); > > + if (paddr >= rtas_rmo_buf && paddr < (rtas_rmo_buf + > > RTAS_RMOBUF_MAX)) > > It probably cannot overflow with actual values of rtas_rmo_buf > and RTAS_RMOBUF_MAX, but otherwise it is an incorrect test; > please write > > if (paddr >= rtas_rmo_buf && paddr - rtas_rmo_buf < RTAS_RMOBUF_MAX) > > (and, _MAX? Shouldn't it be the actual size here? Or is _MAX > just a confusing name :-) ) The original code is a lot more readable and perfectly correct for all possible values of rtas_rmo_buf :-) Cheers, Ben.