sscanf format specification '%u' expects type 'unsigned int *'
for 'u', but parameter 3 has a different type 'int*'.
Pointer 'cfs_crypto_hash_type(d->hd_hash->ha_id)' returned from
call to function 'cfs_crypto_hash_type' at line 261 may be NULL
and will be dereferenced at line 261.
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: I9945a7e5d44329aa6417946106212cb269395290
Reviewed-on: http://review.whamcloud.com/9400
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
- if (sscanf(str, "%u%n", &cpt, &n) < 1) {
+ if (sscanf(str, "%d%n", &cpt, &n) < 1) {
CERROR("Invalid cpu pattern %s\n", str);
goto failed;
}
CERROR("Invalid cpu pattern %s\n", str);
goto failed;
}
int
libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
{
int
libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
{
- int a;
- int b;
- int c;
- int d;
- int n = nob; /* XscanfX */
+ unsigned int a;
+ unsigned int b;
+ unsigned int c;
+ unsigned int d;
+ int n = nob; /* XscanfX */
/* numeric IP? */
if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
/* numeric IP? */
if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
libcfs_str2net_internal(const char *str, __u32 *net)
{
struct netstrfns *nf = NULL;
libcfs_str2net_internal(const char *str, __u32 *net)
{
struct netstrfns *nf = NULL;
- int nob;
- int netnum;
- int i;
+ int nob;
+ unsigned int netnum;
+ int i;
for (i = 0; i < libcfs_nnetstrfns; i++) {
nf = &libcfs_netstrfns[i];
for (i = 0; i < libcfs_nnetstrfns; i++) {
nf = &libcfs_netstrfns[i];
int cfs_crypto_hash_final(struct cfs_crypto_hash_desc *desc,
unsigned char *hash, unsigned int *hash_len)
{
int cfs_crypto_hash_final(struct cfs_crypto_hash_desc *desc,
unsigned char *hash, unsigned int *hash_len)
{
+ const struct cfs_crypto_hash_type *type;
struct hash_desc *d = (struct hash_desc *)desc;
struct hash_desc *d = (struct hash_desc *)desc;
- int size = (cfs_crypto_hash_type(d->hd_hash->ha_id))->cht_size;
- int err;
+ int size;
+ int err;
+
+ LASSERT(d != NULL);
+ type = cfs_crypto_hash_type(d->hd_hash->ha_id);
+ LASSERT(type != NULL);
+ size = type->cht_size;
if (hash_len == NULL) {
kfree(d);
if (hash_len == NULL) {
kfree(d);
LASSERT(d->hd_hash->final != NULL);
err = d->hd_hash->final(d->hd_ctx, hash, *hash_len);
if (err == 0) {
LASSERT(d->hd_hash->final != NULL);
err = d->hd_hash->final(d->hd_ctx, hash, *hash_len);
if (err == 0) {
- /* If get final digest success free hash descriptor */
- kfree(d);
+ /* If get final digest success free hash descriptor */
+ kfree(d);