From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Subject: [PATCH] staging: ccree: Use sizeof(variable) in memory allocs Date: Sun, 30 Jul 2017 22:29:02 +0200 Message-ID: <20170730202902.8953-1-simon@nikanor.nu> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, driverdev-devel@linuxdriverproject.org, linux-crypto@vger.kernel.org, =?UTF-8?q?Simon=20Sandstr=C3=B6m?= To: gilad@benyossef.com Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" List-Id: linux-crypto.vger.kernel.org Rml4ZXMgOSBjaGVja3BhdGNoLnBsIHdhcm5pbmdzIG9mIHR5cGUKIlByZWZlciBrbWFsbG9jKHNp emVvZih2YXJpYWJsZSkuLi4pIG92ZXIga21hbGxvYyhzaXplb2YodHlwZSkuLi4pIgppbiBzdGFn aW5nL2NjcmVlLgoKU2lnbmVkLW9mZi1ieTogU2ltb24gU2FuZHN0csO2bSA8c2ltb25AbmlrYW5v ci5udT4KLS0tCiBkcml2ZXJzL3N0YWdpbmcvY2NyZWUvc3NpX2FlYWQuYyAgICAgICAgfCA0ICsr LS0KIGRyaXZlcnMvc3RhZ2luZy9jY3JlZS9zc2lfY2lwaGVyLmMgICAgICB8IDUgKystLS0KIGRy aXZlcnMvc3RhZ2luZy9jY3JlZS9zc2lfZHJpdmVyLmMgICAgICB8IDMgKystCiBkcml2ZXJzL3N0 YWdpbmcvY2NyZWUvc3NpX2hhc2guYyAgICAgICAgfCA4ICsrKystLS0tCiBkcml2ZXJzL3N0YWdp bmcvY2NyZWUvc3NpX2l2Z2VuLmMgICAgICAgfCA1ICsrKy0tCiBkcml2ZXJzL3N0YWdpbmcvY2Ny ZWUvc3NpX3JlcXVlc3RfbWdyLmMgfCAyICstCiA2IGZpbGVzIGNoYW5nZWQsIDE0IGluc2Vyd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