From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f178.google.com ([209.85.212.178]:33050 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934509AbbGHOAG convert rfc822-to-8bit (ORCPT ); Wed, 8 Jul 2015 10:00:06 -0400 Received: by wiwl6 with SMTP id l6so345739094wiw.0 for ; Wed, 08 Jul 2015 07:00:04 -0700 (PDT) From: Michal Nazarewicz To: Krzysztof Opasiak , balbi@ti.com Cc: stable@vger.kernel.org, david.fisher1@synopsys.com, gregkh@linuxfoundation.org, andrzej.p@samsung.com, m.szyprowski@samsung.com, linux-usb@vger.kernel.org, Krzysztof Opasiak Subject: Re: [PATCH v3 4/5] usb: gadget: mass_storage: Use static array for luns In-Reply-To: <1436281065-32407-5-git-send-email-k.opasiak@samsung.com> References: <1436281065-32407-1-git-send-email-k.opasiak@samsung.com> <1436281065-32407-5-git-send-email-k.opasiak@samsung.com> Date: Wed, 08 Jul 2015 16:00:02 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: stable-owner@vger.kernel.org List-ID: On Tue, Jul 07 2015, Krzysztof Opasiak wrote: > This patch replace dynamicly allocated luns array with static one. > This simplifies the code of mass storage function and modules. > > It also fix issue with reporting wrong number of LUNs in GET_MAX_LUN > request. According to MS spec we should return the max index of valid > LUN, not the number of luns - 1. This is no longer true, is it? Why my fix this bug has been solved, no? As such, this should not go to stable. Or am I missing something? > Reported-by: David Fisher > Signed-off-by: Krzysztof Opasiak Acked-by: Michal Nazarewicz > CC: stable@vger.kernel.org # 3.13+ > @@ -490,6 +489,16 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) > spin_unlock(&common->lock); > } > > +static int _fsg_common_get_max_lun(struct fsg_common *common) Perhaps even ‘unsigned’. > +{ > + int i = ARRAY_SIZE(common->luns) - 1; Ditto. This applies in other places of the patch so I won’t keep repeating it. > + > + while (i >= 0 && !common->luns[i]) > + --i; > + > + return i; > +} > + > static int fsg_setup(struct usb_function *f, > const struct usb_ctrlrequest *ctrl) > { > @@ -2552,12 +2562,11 @@ static int fsg_main_thread(void *common_) > > if (!common->ops || !common->ops->thread_exits > || common->ops->thread_exits(common) < 0) { > - struct fsg_lun **curlun_it = common->luns; > - unsigned i = common->nluns; > + int i; > > down_write(&common->filesem); > - for (; i--; ++curlun_it) { > - struct fsg_lun *curlun = *curlun_it; > + for (i = 0; i < ARRAY_SIZE(common->luns); --i) { ++i > + struct fsg_lun *curlun = common->luns[i]; > if (!curlun || !fsg_lun_is_open(curlun)) > continue; > -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +------ooO--(_)--Ooo--