Re: [PATCH] i2c: add extra check to safe DMA buffer helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 12, 2019 at 2:46 AM Wolfram Sang <wsa@xxxxxxxxxxxxx> wrote:
>
>
> > How about also printing some warning if threshold is zero? Since
>
> Hmm, not a warning because a user of a kernel can't do much about it. A
> debug might make sense; it is for developers and will be compiled away
> for production use.
>
> > caller might expect that if msg->len >= threshold, they will get valid
> > pointer. But they will get valid pointer if (msg->len, threshold) is
> > (>0, 0) and NULL if (=0, 0). So warn them that the threshold is bogus.
>
> Well, callers should always check for NULL because a valid pointer can
> not be guaranteed (ENOMEM case). And I still don't get why would you
> want a valid DMA-able pointer if the msg length is 0?

Yes. But I think the debug message here is just to tell caller that
threshold == 0 might not make sense. For threshold > 0, msg->len >=
threshold returns valid. But it's not the case when threshold is 0.
Also, threshold is 0 and 1 behaves the same: msg->len == 0 returns
NULL, msg->len > 0 returns valid.

>
> Thanks!
>
> -----BEGIN PGP SIGNATURE-----
>
> iQIzBAABCAAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAlyGrQIACgkQFA3kzBSg
> Kbb61Q//XZoT6dJYvO2WdyhYQf2Zpb4S1JEwSkMxa1XRQmw4caIdOLyJVt+OPzFo
> 6Swbg0GQbFPV0tagj9VRTTWWTA6biRf69t+d5fNCMFWJ4Rx89CuJvy1EOA6A8LHN
> Ckce/8HUXJAFdIaMwlkCagwepfO3WJ7GYDrGxiOM9e8cCOGkNgw/bXe3Xks2rcgC
> 8eFiUGqDrrG3LwsTlqBfjBC1aErwYgC/QBO0uhWiodkszggEV8T1D9ykbfTSOvCr
> LHZro3jzmR8E+K1zsujXuP2eDAhaN5V1s7VNI2mrzsQcxl/v7YKd17Us5Iqzq/1d
> 4Ynv0gr7kTLoq5wOv5gamESXQ+m8PBmU7gikrIBh7ie0HXXyQY1U7sO5iSwBoMwC
> eMegBAK8IDr5qM2YAb+urQQ/w7NdA731cYpm0+srfVSsxdpCvWJSROXHjRcrBzkm
> xkw9fY0s5l5hWzWtjrOocYVd68MOmj6hnVFW6n9itAuRsi7CZJ4UnxxpcCbBgfEQ
> +fhru8D6Ie1VkUtLtQlNFh61KJDTZ1Sg2YisL1M1N/nRAH22pSaMxyX2kpXsZI7f
> WsCVIj3Rgow6vOqqUa85aYOqcyWllO29AMTMu+srAbfUWTIZ6iTtB5Dz5bC9oUPN
> YyfviJYySO6UocuuZH1AAmvPdoqlly11ouTiA69vlPIx0hW8o9U=
> =ZJU8
> -----END PGP SIGNATURE-----



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux