Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2170786rdh; Tue, 26 Sep 2023 15:03:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGvahAik8aVqDT69pI5y7NQRmiuJjS9yaLPXIy+No4u/ZtQevaN5LXqwbk8Chf9tgcXC6g X-Received: by 2002:a17:902:f685:b0:1c4:638:fff4 with SMTP id l5-20020a170902f68500b001c40638fff4mr71479plg.17.1695765826769; Tue, 26 Sep 2023 15:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695765826; cv=none; d=google.com; s=arc-20160816; b=S2vtgmli6TEp98WBaWTy7GEMLv2Kd2+mDd6OEcjzGz8PawnpyMmVkjmBVKSFMZ7eeB UPlz4ANfBgSOhfcwjZyM1Vyv/lEBjpRZ6jI84q5+wo+utJt7x1Gha1ELq7hPoNwThD4Q VSo3dqM4vANFGHe+yOmCU14jFX4cqqSsmVYst703vMQUnDTfOTjUxWbaDS96Nc/EbGTT QMcM5CBE+gVTDZx33u5otlm6xJ86vqtFwqUM20G5gC7X7WrmVUCI4wUkhgT2IU5stqeP KCyWEnxJ8tcn9eIVrtGjqdyKKX311zyy7HG4+VE7bcRrAUTg8GHXwveuDFZCfgRqG7xs PawQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=R+ia+cvPbH+bAmUJdDBEKuS5Qt5VtNGnE7cTeyzU36c=; fh=aU1ABjuSFMy3qh2J5e+F+xyxwL+Xq+mADGg3AAS/9JU=; b=EP8O3hUlFMuezz6xawhVAxy5ATTaZIXYeBtoOMIcaCaMS2jr/t8BQndtRSPH2j3l57 7OuOH5y2N50V2yblkMn4ngZCkWmDwwC4Ny/iq8SsB/O/DgBWtfvZ6OzCGZJVflDtWreS sGwBF8nvb4rCI3p/vhMAD992kwshkpkBmLSARdO1eYQ/tW1icOStNtuYpkR/PjR5fMKo xmcKtFAnYNs/g6X15UD7zcASES1gBhKRipD4Vqp4a+gb1r4qlfRUPtcHqA2P5q8LXkmJ NUa2ycYQGxOijHw1+Pc4igEsz7/AJyU4BEqmevuDvgvcBRCgWyJM6SZqgpVmUuEgEVRK xuKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=C0i1sssx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id b11-20020a170902d50b00b001b811261289si14893283plg.482.2023.09.26.15.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 15:03:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=C0i1sssx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0DF9680765DD; Mon, 25 Sep 2023 23:31:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233757AbjIZGax (ORCPT + 99 others); Tue, 26 Sep 2023 02:30:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233751AbjIZGaw (ORCPT ); Tue, 26 Sep 2023 02:30:52 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8636CF2; Mon, 25 Sep 2023 23:30:45 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38Q4PT08011646; Tue, 26 Sep 2023 06:30:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : from : subject : to : cc : references : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=R+ia+cvPbH+bAmUJdDBEKuS5Qt5VtNGnE7cTeyzU36c=; b=C0i1sssxbEYTw7HFwLJWS0jO2h86SODfro9WKkN7jtM7CjsFnp3Tr/QOfmlgD2TAc/xW 3418N/Iqby07DTxj+35Hk6vvaosfIo/FA+5OiBHl+NgaJDPZ+99EJ0w1gq4ZCZ4zIpCO AzTT+X+1X/ItftZq0D4ssZsgeeu+rzl+nGo5CQEEPpPzh5FDrGiIYIpzimH3ahCKwv0D ld3TOBhkg1I8tDjznu88yGpMmS+aBZVloB/KItL/eYbvz/5yIkqZlqqmDFmeD1SFdQJd gtaRx9WGDOmYAdLbmPXVD+9BBX3f2aqBogkjIMakvy5yQ6EXGkDqPAalt6k3g9jwuB6t AA== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tbexgh4n5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Sep 2023 06:30:43 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38Q6UfvU027087 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Sep 2023 06:30:41 GMT Received: from [10.216.11.3] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Mon, 25 Sep 2023 23:30:38 -0700 Message-ID: Date: Tue, 26 Sep 2023 12:00:35 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Krishna Kurapati PSSNV Subject: Re: [PATCH v2] usb: gadget: ncm: Handle decoding of multiple NTB's in unwrap call To: Greg Kroah-Hartman CC: Linyu Yuan , =?UTF-8?Q?Maciej_=C5=BBenczykowski?= , , , , , , References: <20230915061001.18884-1-quic_kriskura@quicinc.com> <2023091743-tightly-drivable-4360@gregkh> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: uA439euBvtP9-O0uDRSYY4dV1SETZexH X-Proofpoint-GUID: uA439euBvtP9-O0uDRSYY4dV1SETZexH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-26_04,2023-09-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 impostorscore=0 mlxlogscore=996 adultscore=0 clxscore=1015 bulkscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309260057 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 25 Sep 2023 23:31:09 -0700 (PDT) On 9/18/2023 1:07 PM, Krishna Kurapati PSSNV wrote: > > > On 9/17/2023 1:34 PM, Greg Kroah-Hartman wrote: >>> Cc: stable@vger.kernel.org >> >> What commit id does this fix? >> > > Hi Greg, > > This fixes the initial patch that added the driver: > 9f6ce4240a2bf456402c15c06768059e5973f28c > >>> Reviewed-by: Maciej Żenczykowski >>> Signed-off-by: Krishna Kurapati >>> --- >>>   drivers/usb/gadget/function/f_ncm.c | 26 +++++++++++++++++++------- >>>   1 file changed, 19 insertions(+), 7 deletions(-) >>> >>> diff --git a/drivers/usb/gadget/function/f_ncm.c >>> b/drivers/usb/gadget/function/f_ncm.c >>> index feccf4c8cc4f..f00f051438ec 100644 >>> --- a/drivers/usb/gadget/function/f_ncm.c >>> +++ b/drivers/usb/gadget/function/f_ncm.c >>> @@ -1156,7 +1156,8 @@ static int ncm_unwrap_ntb(struct gether *port, >>>                 struct sk_buff_head *list) >>>   { >>>       struct f_ncm    *ncm = func_to_ncm(&port->func); >>> -    __le16        *tmp = (void *) skb->data; >>> +    unsigned char    *ntb_ptr = (void *) skb->data; >> >> Why persist with the extra ' ', didn't checkpatch complain about this? >> >> And why the cast at all? >> > My bad. I ran the checkpatch and got the following result: > > kriskura@hu-kriskura-hyd:/local/mnt/workspace/krishna/510/testncm/kernel$ ./scripts/checkpatch.pl --strict 0001-usb-gadget-ncm-Handle-decoding-of-multiple-NTB-s-in-.patch > WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit > description?) > #12: > unwraps the obtained request data assuming only one NTB is present, we > loose > > CHECK: No space is necessary after a cast > #34: FILE: drivers/usb/gadget/function/f_ncm.c:1159: > +       unsigned char   *ntb_ptr = (void *) skb->data; > > CHECK: No space is necessary after a cast > #46: FILE: drivers/usb/gadget/function/f_ncm.c:1176: > +       tmp = (void *) ntb_ptr; > > CHECK: No space is necessary after a cast > #93: FILE: drivers/usb/gadget/function/f_ncm.c:1329: > +               ntb_ptr = (unsigned char *) (ntb_ptr + block_len); > > total: 0 errors, 1 warnings, 3 checks, 67 lines checked > > > I ignored the checks and saw only that errors are 0. Seems like I missed > fixing the commit text wrapping to 75 chars (On line 12 it has 76 > chars). Will fix it up in v3. > > As per the cast, I initially didn't add any cast and saw that the code > was not able to parse the dwSignature of the NTH and decoding of all > packets was failing. Only when I added the cast, was the function able > to decode all packets properly. > >>> +    __le16        *tmp; >>>       unsigned    index, index2; >>>       int        ndp_index; >>>       unsigned    dg_len, dg_len2; >>> @@ -1169,6 +1170,10 @@ static int ncm_unwrap_ntb(struct gether *port, >>>       const struct ndp_parser_opts *opts = ncm->parser_opts; >>>       unsigned    crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; >>>       int        dgram_counter; >>> +    int        to_process = skb->len; >>> + >>> +parse_ntb: >>> +    tmp = (void *) ntb_ptr; >> >> Again, no blank space please. >> >> And why the cast? >> > the second cast here was just to be in sync with the original code; > __le16        *tmp = (void *) skb->data; > > I didn't try removing this and running the test. Will check if the > second one is required or if decoding is proper without it or not. > > Regards, > Krishna, Hi Greg, I rechecked the code and I don't see any error if I remove the typecast for ntb_ptr. If I remove the typecast for tmp, I see build errors as ntb_ptr is unsigned char and tmp is __le16. I have pushed v3 removing the typecast for ntb_ptr and fixing the checkpatch errors. Thanks for pointing out that the typecast is not needed. Regards, Krishna,