Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1385472yba; Thu, 4 Apr 2019 09:41:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnFMqxxpcG2aF8Xj1VgWys8ahtbwjDS3i7h+OOwhdNzosH6NZFcOVUxbxaBamLSCe0lIWK X-Received: by 2002:a65:4108:: with SMTP id w8mr6851148pgp.236.1554396069806; Thu, 04 Apr 2019 09:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554396069; cv=none; d=google.com; s=arc-20160816; b=SvjrGPuGP32Cid/a4GeE3C5W+cft9uZwvoIWt7aP8m1nhM+uWLK+EbMVCxeXajOVbx 9Sz91tCLeFyaMRv08J9orvIaLkAdBVCRqGdu51H0gWFnAz2p/xZEgUjRtyYQ8WJW+q6k PnYCxUeOlZh449mbgEHkWr9Gtk3bOjwm/ndCOj14O2xxvSO3GBsqBEoO8nQ73B02HRCG aK0qQxXf9jXbW3gB2J+25LPuthGV3h5BDabd7I7o2WB2Rk8Y5yPbm0Ueg/qzBL7nJ7Um WXNlHBslDT+JjdbRub5tddvKoGHCbmpbd1aNh4dpILKbgN9w61bv0dSxJTz4b0o/BHmQ XKaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dmarc-filter :dkim-signature:dkim-signature; bh=Ao092/nb2HZ71xjy6TBvhLVd6eUISRt4Yot5K/KNXFM=; b=ltypVgsmTLZ6cdk97+lMnPTW1LA23h4LoMpZo1lQOc5Nk5pETIOnvRbuXU4ZhtL3zP cdYaoW/W8mzpeT+FUewP/k7ZNx0EdBTkm+65FH7xhoT35SMTVAqWWMMKBqefH5at2WY4 nX34qclizl8ZKd6xei4uBAdY06fBN1nv+cTHl7oDBgyUSKKvWsZuMB5rryYx2/C1ISIR C/cBbgeFHTurvF6IPjImEcofAU+tp+Qi9AgrhGswruiachuJjhUpf37hBzvSQQd7OoNJ pXEyYwNu4bTaETRGY5Y0uZb8kEF7BmsIhzKEWdSoTvYnag5MnbnwOhtKwa9Pjh44mcnH JF9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=g8ut8LyD; dkim=pass header.i=@codeaurora.org header.s=default header.b=gV3uonkc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u20si16472304pgi.431.2019.04.04.09.40.54; Thu, 04 Apr 2019 09:41:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=g8ut8LyD; dkim=pass header.i=@codeaurora.org header.s=default header.b=gV3uonkc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729477AbfDDQkN (ORCPT + 99 others); Thu, 4 Apr 2019 12:40:13 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43294 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727191AbfDDQkM (ORCPT ); Thu, 4 Apr 2019 12:40:12 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1A96A60746; Thu, 4 Apr 2019 16:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1554396011; bh=gGxqswoSC8eyw2H1E80LMaN0g64Olwvj3RMSqJJYLYQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=g8ut8LyDMbhIFK9oiU6YpFyZIXFGi+TiomvzGy+Tc9uGyWYoC9JxFdYoVJ+Yy9h7m JxFFlxNEOQl/cG/DNNl06Tr5rUKHp8STX/Sai6rWWHecYuK3LTGRVKaA2ijlNtdxND 1kLHNb0VroZNYU5OME0l2gdNG0qiULjXkUnUTKiY= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4238560350; Thu, 4 Apr 2019 16:40:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1554396010; bh=gGxqswoSC8eyw2H1E80LMaN0g64Olwvj3RMSqJJYLYQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=gV3uonkcBikVeo1pPwwneFXwapnPVs8SaFW5+OSquWc+rju5CjnSW73hjei0UTEkH DhmL6vH/MG3rY2kP7dpQ4p2pbxWkpzxgdIrsEifHbdRLlZ0lXuG28iKFqL+sZhI/RQ MfyxskMDSnzcBMCeJozRCMqdu5nhaaBCx2IVwPxc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4238560350 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: "Gustavo A. R. Silva" Cc: Sergey Matyukevich , Igor Mitsyanko , Avinash Patil , Sergey Matyukevich , "David S. Miller" , "linux-wireless\@vger.kernel.org" , "netdev\@vger.kernel.org" , "linux-kernel\@vger.kernel.org" Subject: Re: [PATCH][next] qtnfmac: replace qtnf_cmd_acl_data_size() with struct_size() References: <20190403170236.GA31637@embeddedor> <20190404133234.2uatru2vlw3ntrmv@bars> <3baa19c1-a213-3dcf-2f03-23b058ec419a@embeddedor.com> Date: Thu, 04 Apr 2019 19:40:06 +0300 In-Reply-To: <3baa19c1-a213-3dcf-2f03-23b058ec419a@embeddedor.com> (Gustavo A. R. Silva's message of "Thu, 4 Apr 2019 11:33:56 -0500") Message-ID: <87imvtsp09.fsf@kamboji.qca.qualcomm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Gustavo A. R. Silva" writes: > On 4/4/19 11:01 AM, Gustavo A. R. Silva wrote: >> >> >> On 4/4/19 8:32 AM, Sergey Matyukevich wrote: >>>> One of the more common cases of allocation size calculations is finding >>>> the size of a structure that has a zero-sized array at the end, along >>>> with memory for some number of elements for that array. For example: >>>> >>>> struct foo { >>>> int stuff; >>>> struct boo entry[]; >>>> }; >>>> >>>> size = sizeof(struct foo) + count * sizeof(struct boo); >>>> instance = kzalloc(size, GFP_KERNEL) >>>> >>>> Instead of leaving these open-coded and prone to type mistakes, we can >>>> now use the new struct_size() helper: >>>> >>>> size = struct_size(instance, entry, count); >>>> >>>> or >>>> >>>> instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL) >>>> >>>> Based on the above, replace qtnf_cmd_acl_data_size() with the >>>> new struct_size() helper. >>>> >>>> This code was detected with the help of Coccinelle. >>>> >>>> Signed-off-by: Gustavo A. R. Silva >>>> --- >>>> drivers/net/wireless/quantenna/qtnfmac/commands.c | 15 ++++----------- >>>> 1 file changed, 4 insertions(+), 11 deletions(-) >>> >>> Hi Gustavo, >>> >> >> Hey Sergey, >> >>> Thanks for the patch! By the way, it does not apply cleanly, so it needs >>> to be rebased on top of the up-to-date wireless-drivers-next tree. Let >>> me know if you would prefer me to care about rebase. Then I will >>> add this patch to the upcoming series of qtnfmac fixes. >>> >> >> Don't worry. I'll do it and send this again. >> > > Hmm... I just applied it cleanly on top of wireless-drivers-next/master: > > 973a99be7943 (HEAD) qtnfmac: replace qtnf_cmd_acl_data_size() with struct_size() > 38bb0baea310 (wireless-drivers-next/master) rtlwifi: move spin_lock_bh > to spin_lock in tasklet > 60209d482b97 rtlwifi: fix potential NULL pointer dereference > 765976285a8c rtlwifi: fix a potential NULL pointer dereference > > Do you see any issues with this? Yeah, I also was able to apply it without problems. So it's in w-d-next now :) -- Kalle Valo