From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f49.google.com ([74.125.82.49]:34837 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752417AbbGTNRj convert rfc822-to-8bit (ORCPT ); Mon, 20 Jul 2015 09:17:39 -0400 Received: by wgav7 with SMTP id v7so64899051wga.2 for ; Mon, 20 Jul 2015 06:17:38 -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 Subject: Re: [PATCH v3 4/5] usb: gadget: mass_storage: Use static array for luns In-Reply-To: <55ACCECC.5000609@samsung.com> References: <1436281065-32407-1-git-send-email-k.opasiak@samsung.com> <1436281065-32407-5-git-send-email-k.opasiak@samsung.com> <55ACCECC.5000609@samsung.com> Date: Mon, 20 Jul 2015 15:17:34 +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 07/08/2015 04:00 PM, Michal Nazarewicz wrote: >> 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? On Mon, Jul 20 2015, Krzysztof Opasiak wrote: > Unfortunately it's still true. Your fix solved this bug partially. Now > we report nluns - 1 instead of FSG_LUN_MAX but in case of not contiguous > luns it is not enough. > > Let's consider mass storage function with luns 0 1 3 5. nluns == 4 so in > GET_MAX_LUN we will return 3 (nluns - 1). I don’t believe that’s accurate. See loop in my patch: + if (!opts->refcnt) { + for (nluns = i = 0; i < FSG_MAX_LUNS; ++i) + if (common->luns[i]) + nluns = i + 1; + if (!nluns) + pr_warn("No LUNS defined, continuing anyway\n"); + else + common->nluns = nluns; + pr_info("Number of LUNs=%u\n", common->nluns); + } It iterates over all luns and if lun is non-NULL it sets nluns to index of that lun plus one. So if luns[0], lun[1], lun[2], lun[3] and lun[5] are set, common->nluns = 6. -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +------ooO--(_)--Ooo--